Ispas Claudiu
Ispas Claudiu

Reputation: 1998

Qt recording video using QMediaRecorder not working

I have a problem recording a video in qt. I will be very happy if someone knows the answer or gives a hint. :)

I am using:

  1. Windows 7 64bit
  2. QT 5.1.1
  3. MSVC 2010 32bit with OpenGL

The problem:

I followed the example explained in the Documentation (http://qt-project.org/doc/qt-5.0/qtmultimedia/cameraoverview.html) and also(http://www.meetingcpp.com/index.php/br/items/recording-videos-with-qt5.html) and did it like this:

 m_camera = new QCamera;
 m_mediaRecorder = new QMediaRecorder(m_camera);
...
...
 QVideoEncoderSettings settings =  m_mediaRecorder->videoSettings();
 settings.setResolution(800, 600);
 settings.setQuality(QMultimedia::LowQuality);
 settings.setFrameRate(30.0);
 m_mediaRecorder->setVideoSettings(settings);
...
 m_camera->setCaptureMode(QCamera::CaptureVideo);
...
 m_camera->focus();

on button record click:

m_camera->focus();
bool ret = m_mediaRecorder->setOutputLocation(QUrl::fromLocalFile("testvideo.mp4"));
qDebug()<<"ret: "<<ret;
m_mediaRecorder->record();

on button stop:

m_mediaRecorder->stop();

The idea is that no output video exists. I printed the return of the function m_mediaRecorder.setOutputLocation() which always returns false. The documentation gives an example of how can setOutputLocation fail (using QUrl network, which is not my case) but does not specify how can fail using local QUrl. I supposed that giving the incorrect path can make mediaRecorder complain so I tried also the following:

bool ret = m_mediaRecorder->setOutputLocation(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + "/" + "testvideo.mp4"));
bool ret = m_mediaRecorder->setOutputLocation(QUrl("file:///path/to/my/working/directory/testvideo.mp4"));

but it also fails :|.

Can someone help me with this problem? Thank you very much in advance!

Upvotes: 3

Views: 4150

Answers (1)

Solidus
Solidus

Reputation: 718

It seems the problem is that the recording is still not working for windows due to a plugin change not yet fully implemented, as explained here

I tested it on a mac and it worked fine. To fix this on windows I used the QtMEL library.

Upvotes: 2

Related Questions