PDA

View Full Version : can't see a video play but only music in Qt



baluk
8th October 2010, 13:14
Hi,

I want to play a video in my application. But whenever I try to runt he application, I get the message "WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no objectName ) to Phonon::VideoWidget ( no objectName )." And I can hear the music but not video. Here is my code



MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
Phonon::VideoPlayer *player =
new Phonon::VideoPlayer(Phonon::VideoCategory, this);
player->play(QUrl("path"));
player->show();
}

#include <QMainWindow>
#include <phonon/VideoPlayer>
#include <phonon/backendcapabilities.h>
#include <QUrl>
#include <phonon>
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private:
Ui::MainWindow *ui;
};


I tried to run the code from http://www.qtcentre.org/threads/30480-Play-video-file-with-Phonon-and-GStreamer-show-black-screen but didn't work. Can any one please tell me what else should be required to play a video.

Thank You,
Baluk

tbscope
8th October 2010, 16:15
You have the correct decoder installed?

baluk
8th October 2010, 17:39
I am sorry but what decoder I should use. I thought Qt takes the default one that is provided in my windows vista, isn't it so. I don't have much idea about decoder stuff I am trying to find it anyway.

Thank You,
Baluk

squidge
8th October 2010, 18:12
Unless you have a codec capable of playing the video, all you'll get is audio.

We can't tell you which decoder to use as we don't know your file format.

baluk
8th October 2010, 20:11
I want to play avi, mp3 and mkv format file.

squidge
8th October 2010, 20:32
avi and mkv are only containers, what is the file type that you will be playing inside those containers? eg. xvid.

baluk
8th October 2010, 20:47
oke. File type is VLC media file.

squidge
8th October 2010, 21:53
No, it's not.

That's just the registered player you are using to play the file.

baluk
9th October 2010, 08:19
Oke. Now I got to understand what is file format. I want to play avc1 and MPGV codec files.

squidge
9th October 2010, 13:38
Install FFDShow

baluk
9th October 2010, 20:26
I have it installed on my system. My audio was playing with this codec support only.

hicham
9th October 2010, 21:11
http://bugreports.qt.nokia.com/browse/QTBUG-13062

baluk
10th October 2010, 15:43
http://bugreports.qt.nokia.com/browse/QTBUG-13062

So according to the link, I can't play a video using Qt 4.7. Is there any other way I could make it possible.

baluk
11th October 2010, 07:22
I moved to Qt 4.6.2 and tried to run my application. But I still couldn't succeed. Here I am copying my code. Could any one please check If it is running on your system.



#include <QMainWindow>
#include <phonon/VideoPlayer>
#include <phonon/VideoWidget>
#include <phonon/backendcapabilities.h>
#include <QUrl>
#include <phonon>
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();

protected:
void changeEvent(QEvent *e);

private:
Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H

//.CPP file

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

qDebug() << Phonon::BackendCapabilities::availableAudioOutputD evices();

Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);

Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget(this);
Phonon::createPath(mediaObject, videoWidget);

Phonon::AudioOutput *audioOutput =
new Phonon::AudioOutput(Phonon::VideoCategory, this);
Phonon::createPath(mediaObject, audioOutput);
mediaObject->setCurrentSource(QUrl("file.mkv or .avi"));
connect(mediaObject, SIGNAL(finished()), mediaObject, SLOT(deleteLater()));
mediaObject->play();

}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}

//.pro file

#-------------------------------------------------
#
# Project created by QtCreator 2010-10-10T23:15:17
#
#-------------------------------------------------

QT += opengl phonon multimedia

TARGET = video
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

wince*{
DEPLOYMENT_PLUGIN += phonon_ds9 phonon_waveout
}




Thank You,
baluk

baluk
15th October 2010, 13:36
Hi,

My problem is solved. Now I can play a video in my Qt app. It was solved when I enable the corresponding decoder in the ffdshow video decoder ( which is responsible for all format video play). Before I was overlooked the issue when running the application.

somnathbanik
3rd November 2010, 06:21
Hi,

My problem is solved. Now I can play a video in my Qt app. It was solved when I enable the corresponding decoder in the ffdshow video decoder ( which is responsible for all format video play). Before I was overlooked the issue when running the application.

Hi,
I am new to Qt and facing the same issue. I am using windows XP and also install k-Lite codec, but still not working, then I uninstalled that and installed FFDSHOW, do I need to configure anywhere in my system. Please suggest me.

baluk
4th November 2010, 14:16
Did you open the ffdshow window and check the available video types and if they are enabled or disabled.

xairoy
3rd January 2011, 16:27
I tried to play DIVX encoded .avi file. But it is not playing. I have also installed ffdshow and I have checked that DIVX XIDV codecs are enabled. Can somebody help me.

Chiz
10th January 2011, 16:53
Hi,

My problem is solved. Now I can play a video in my Qt app. It was solved when I enable the corresponding decoder in the ffdshow video decoder ( which is responsible for all format video play). Before I was overlooked the issue when running the application.

Can you write, where and what did you do to see video?

mk_researchfellow
13th May 2013, 11:17
can anybody tell me in ffdshow video decoder what option shud i enable for playing .avi video file.I can only hear the music but no video........