Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED]Can't set output location for QMediaRecorder

[SOLVED]Can't set output location for QMediaRecorder

Scheduled Pinned Locked Moved Mobile and Embedded
10 Posts 2 Posters 4.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    igor64
    wrote on last edited by
    #1

    Hi everybody!

    I am trying to save video from my camera into the file but I can't set the output location. The method SetOutputLocation always returns FALSE.
    Bellow is the code:

    @
    QCamera * camera;
    QMediaRecorder * rec;

    QApplication app(argc, argv);
    
    
    camera = new QCamera;
    
    camera->setCaptureMode(QCamera::CaptureVideo);
    
    camera->start();
    
    rec = new QMediaRecorder(camera);
    
    QString file = "D:\\qt\\test\\test.avi";
    
    QFile file1(file);
    
    file1.open(QIODevice::WriteOnly);
    

    rec->setOutputLocation(QUrl::fromLocalFile(file));
    @

    What should I do to fix this problem?

    Thanks in advance.

    Igor

    [edit: please add @ tags around your code for better readability, Eddy]

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stevenceuppens
      wrote on last edited by
      #2

      I Quickly tested your code on mac, and it works..

      I guess i has something todo with the filePath

      can your try:

      @QString file = QCoreApplication::applicationDirPath() + "/testings.avi";@

      Steven CEUPPENS
      Developer / Architect
      Mobile: +32 479 65 93 10

      1 Reply Last reply
      0
      • I Offline
        I Offline
        igor64
        wrote on last edited by
        #3

        I tried as you wrote. No change.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          igor64
          wrote on last edited by
          #4

          I checked:

          camera->isCaptureModeSupported(QCamera::CaptureVideo);

          and it returned False.

          Could it be the reason? I use simple web camera. Are these methods camera dependent?

          And if the camera is the reason, what kind of camera should I have to have in order to do this?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stevenceuppens
            wrote on last edited by
            #5

            i tested your code on Mac, and it worked out of the box with my build in camera...

            What platform do you use ?

            Steven CEUPPENS
            Developer / Architect
            Mobile: +32 479 65 93 10

            1 Reply Last reply
            0
            • I Offline
              I Offline
              igor64
              wrote on last edited by
              #6

              Windows XP 2002, SP3.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                stevenceuppens
                wrote on last edited by
                #7

                Did you compile directshow plugin ?

                http://qt-project.org/forums/viewthread/19150

                Steven CEUPPENS
                Developer / Architect
                Mobile: +32 479 65 93 10

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  igor64
                  wrote on last edited by
                  #8

                  No, I didn't. I installed QtCreator and that's all. Where can I get this plugin and what should I do to compile it?

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    igor64
                    wrote on last edited by
                    #9

                    Beacuse I couldn't make it work with QCamera and QMediaRecorder, I installed OpenCV. I typed the code:

                    @
                    #include "opencv2/highgui/highgui.hpp"
                    #include <iostream>

                    using namespace cv;
                    using namespace std;

                    int main(int argc, char* argv[])
                    {
                    VideoCapture cap("clock.avi"); // open the video file for reading
                    if ( !cap.isOpened() ) // if not success, exit program
                    {
                    cout << "Cannot open the video file: " << endl;
                    waitKey(20000);
                    return -1;
                    }

                    }
                    @

                    And the story is the same: "Cannot open the video file".

                    I tried this on 2 different computers (win7, xp) and the result is the same. I installed on both computers the same QT creator.

                    Maybe is something wrong with my installation of the QT. Some rights, pathes, environment variables, ...

                    Any ideas?

                    [edit: added coding tags "@" SGaist]

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      igor64
                      wrote on last edited by
                      #10

                      Hi!

                      I think I found the reason why it doesn't work: codecs. Some files I can read (CRAM codec), most of them I don't. And these things work better with opencv than with QMediaRecorder. So, I need more knowledge on codecs. If anyone knows where to get a good tutorial on using video codecs I would be very grateful.
                      stevenceuppens:: Thank you for your help.

                      Bye

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved