sibtx13
sibtx13

Reputation: 123

qt 5 QMediaPlayer error: Gstreamer unable to play

I just installed QT 5 and am trying to run the example for playing video. The code snippet looks like:

QMediaPlayer *player = new QMediaPlayer;

player->setMedia( QUrl::fromLocalFile(fileUrl)  );

QVideoWidget *videoWidget = new QVideoWidget;
player->setVideoOutput(videoWidget);

videoWidget->show();
player->play();

It compiles fine, but when I run it I get the following error:

GStreamer; Unable to play - "file:sample.avi"

Im on Ubuntu 12.04 and have installed all of the extra gstreamer packages in case gstreamer was missing codecs. Ive tried with a few different video formats to no avail. I can play the videos using vlc just fine. Does anyone have any idea why this isnt working?

Upvotes: 1

Views: 3502

Answers (1)

Deepak
Deepak

Reputation: 480

It needs absolute path. Try

player->setMedia( QUrl::fromLocalFile(QFileInfo(fileUrl).absoluteFilePath()));

Upvotes: 5

Related Questions