Results 1 to 2 of 2

Thread: QMediaRecorder recording QMediaPlayer Video Problems

  1. #1
    Join Date
    May 2017
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QMediaRecorder recording QMediaPlayer Video Problems

    Hi, I am new here. I am trying to record a local video file that is played by a QMediaPlayer. But it seems that the QMediaRecorder is not recording the video that is being played.

    Basically I have a video player that is playing that the video will start recording whenever the user click on the record button.
    Below is the code snippet for my recording function.

    Qt Code:
    1. void VideoPlayer::record()
    2. {
    3. if (!isRecording)
    4. {
    5.  
    6. videoRecorder = new QMediaRecorder(&mediaPlayer);
    7. videoRecorder->setOutputLocation(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + "/" + "testRecord.mp4"));
    8. videoRecorder->record();
    9. isRecording = true;
    10. }
    11. else
    12. {
    13. videoRecorder->stop();
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

    I try debugging and these are the values I got from QMediaRecorder.

    QMediaPlayer state is playing state during recording.
    QMediaRecorder status = UnavailableStatus
    QMediaRecorder state = StoppedState
    QMediaRecorder error = NoError

    What am I doing wrong? This has been bugging me for days and I really need help.
    I am begging on my knees.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QMediaRecorder recording QMediaPlayer Video Problems

    For one thing, your code creates a new QMediaRecorder instance each time you click the record button and isRecording is false. Each of these instances gets attached to the same media player. In the code you posted, these videoRecorder instances are never destroyed.

    You should probably create a single instance of videoRecorder when the media player is created and simply start and stop that instance in the record slot.

    If you are running this program in Windows 7 or 10, be sure you actually have permission to create files in your output directory. You don't have any error checking to see if the call to setOutputLocation() actually succeeded. You also aren't connecting any slots to the signals emitted by QMediaRecorder (statusChanged(), error()), so you have no way of determing what the state of the recorder is.

    Simply assuming that every call works without checking any of the return values gets you to the situation you're in now - it isn't working and you have no idea why.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 0
    Last Post: 1st April 2016, 06:38
  2. Replies: 0
    Last Post: 8th December 2015, 06:11
  3. QMediaPlayer video part saving.
    By antweb in forum Qt Programming
    Replies: 0
    Last Post: 16th June 2015, 11:16
  4. QCamera and recording a video.
    By bird12358 in forum Qt Programming
    Replies: 0
    Last Post: 21st February 2014, 12:16
  5. Replies: 1
    Last Post: 20th July 2012, 16:38

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.