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?
It needs absolute path. Try
player->setMedia( QUrl::fromLocalFile(QFileInfo(fileUrl).absoluteFilePath()));
Related
I am trying to play *.avi file (~900MB) with this code:
QMediaPlayer* player = new QMediaPlayer(this);
player->setMedia(QUrl::fromLocalFile("mes1.avi"));
player->setVideoOutput(ui->videoWidget);
player->play();
where ui->videoWidget is QVideoWidget and every time I play it I am getting this error code (in Application Output console)
Since google doesn't help, this is my only choice...
DirectShowPlayerService::doRender: Unresolved error code 0x80040266 (IDispatch error #102)
EDIT1:
I have installed K-Lite Codec Pack 12.2.6.
EDIT2:
My application is 32bit, but it shouldn't be a problem since K-Lite include 32bit (source).
Use vlc-qt, and you will find it is so easy to play all sorts of video on all platforms, even XP, which has been abandoned by qt long time ago.
I'm running OS X El Capitan and trying to use OpenCV VideoCapture to read an .avi file. I've tried it on both opencv 2.4.1 and 3, both of which have the same outcome.
cv::VideoCapture capture("filename.avi");
cv::Mat currentFrame, prevFrame;
bool capPrevSuccess = capture.read(prevFrame);
bool capCurrSuccess = capture.read(currentFrame);
I've verified that the filename.avi is in the current working directory and I don't see any errors in the console.
I'm beginning to wonder if it's something with my machine. I have a similar problem running VideoReader in MATLAB on the same machine. I believe MATLAB uses OpenCV VideoReader as well, perhaps they're connected.
Error using VideoReader/init (line 619) Failed to initialize internal
resources.
Error in VideoReader (line 172)
obj.init(fileName);
EDIT: Looks like this has something to do with the video files I'm using. I downloaded an mp4 video, and had no trouble with it. Unfortunately I need to use the video files I'm using (all .avi), yet they all seem to not work with VideoCapture.
I'm trying to use a camera in my QT5.5 application using the QCamera type of QT. A simple example of what I'm doing is
QList<QCameraInfo> cameras = QCameraInfo::avalilableCameras();
qdebug() << cameras.length();
const QCameraInfo &cameraInfo = cameras.first();
QCamera *camera = new QCamera( cameraInfo );
When I run this example, I get "No m_videoSink available!" on the command line. QT is build on Ubuntu 12.04 with libgstreamer0.10-0, libgstreamer0.10-dev and libgstreamer-plugins-base0.10-0 installed. QT is built with -qt-xcb. I have no idea what is wrong here. Does anyone have an idea?
PS: Of course I make sure that line 2 prints >= 1 ;).
Ok, finally I found the basic problem: Unfortunately Qt dropped Ubuntu 12.04 LTS support with version 5.5. With version 5.4 everything works as expected.
I want to play video file in qt. But when i am using QMediaPlayer Class, it is throwing an error as : fatal error: No such file or directory.
QMediaPlayer *player = new QMediaPlayer;
QMediaPlaylist *playlist = new QMediaPlaylist(player);
playlist->addMedia(QUrl("http://example.com/myclip1.mp4"));
playlist->addMedia(QUrl("http://example.com/myclip2.mp4"));
QVideoWidget *videoWidget = new QVideoWidget;
player->setVideoOutput(videoWidget);
videoWidget->show();
playlist->setCurrentIndex(1);
player->play();
When i am including QMediaPlayer class it is throwing error.
I am using Qt4.8.4 Version, Ubuntu 12.04 in my system
Are you sure that QMediaPlayer is a feature in 4.8.4?
http://qt-project.org/doc/qt-5/qmediaplayer.html
It looks like it has been introduced with Qt5.
Check out this example for 4.8.4 video playback:
http://qt-project.org/doc/qt-4.8/demos-qmediaplayer.html
Add to the .pro file:
CONFIG += mobility
MOBILITY += multimedia
Check the videoplayer from here, I didn't try it, but it might help you: http://radekp.github.io/qtmoko/api/phonon-videoplayer.html:
I'm using Qt Creator 2.7.2 (Qt 5.1) on Windows 8 Pro x64. I'm having trouble with QMediaPlayer. There are some MP3 files on my PC which run fine on Windows Media Player, but QMediaPlayer can't play them. Following statement:
void MainWindow::onPlayerStateChanged(QMediaPlayer::State state)
{
qDebug() << "onPlayerStateChanged" << state
<< media_player.error() << media_player.errorString();
// ....
}
is the slot connected to media player's stateChanged signal throws following output:
onPlayerStateChanged QMediaPlayer::PlayingState QMediaPlayer::NoError ""
DirectShowPlayerService::doRender: Unresolved error code 80040266
onPlayerStateChanged QMediaPlayer::StoppedState QMediaPlayer::ResourceError ""
DirectShowPlayerService::doRender: Unresolved error code 80040266
Any idea what's wrong?
It might have something to to with the ID3 tags of the file.
I had a similar problem: I was trying to play some MP3 files with QMediaPlayer. One of the files generated that error while the others played fine (on Windows 7). On Linux though, they all played fine.
So I ran the 'file' command on my MP3 files and noticed that the problematic MP3 file had a ID3 version 2.4.0 tag while all the others had ID3 version 2.3.0. I deleted the ID3 tag of that file completely using an ID3 tag editor and after that the file played successfully.
A wild guess here: DirectShow, which is used by QMediaPlayer as backend on Windows, chokes on ID3 version 2.4 and only recognizes older versions. And QMediaPlayer on Linux uses GStreamer as backend, which does not have that problem.