Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    [SOLVED]Can't set output location for QMediaRecorder

    Mobile and Embedded
    2
    10
    3396
    Loading More Posts
    • 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
      igor64 last edited by

      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 Reply Quote 0
      • S
        stevenceuppens last edited by

        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 Reply Quote 0
        • I
          igor64 last edited by

          I tried as you wrote. No change.

          1 Reply Last reply Reply Quote 0
          • I
            igor64 last edited by

            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 Reply Quote 0
            • S
              stevenceuppens last edited by

              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 Reply Quote 0
              • I
                igor64 last edited by

                Windows XP 2002, SP3.

                1 Reply Last reply Reply Quote 0
                • S
                  stevenceuppens last edited by

                  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 Reply Quote 0
                  • I
                    igor64 last edited by

                    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 Reply Quote 0
                    • I
                      igor64 last edited by

                      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 Reply Quote 0
                      • I
                        igor64 last edited by

                        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 Reply Quote 0
                        • First post
                          Last post