Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT's QMediaRecorder not working - Unable to record from camera
Qt 6.11 is out! See what's new in the release blog

QT's QMediaRecorder not working - Unable to record from camera

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 4 Posters 4.9k Views 1 Watching
  • 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.
  • J jack1998

    I'm trying to record a video from two different camera. I am able to show the flux of the camera but the problem is recording, I can save the file but I can't open it.
    can youu help me please

    viewfinderAvant= new QCameraViewfinder(); //le flux
    
    
    if (QCameraInfo::availableCameras().count()>0) 
     {
         cameraAvant = new QCamera("/dev/video4",this); 
         layoutAvant = new QVBoxLayout(); 
         cameraAvant->setViewfinder(viewfinderAvant);
         layoutAvant->addWidget(viewfinderAvant); 
         QCameraViewfinderSettings viewfinderSettings;
         viewfinderSettings.setResolution(800,600);
         cameraAvant->setViewfinderSettings(viewfinderSettings); 
         recorder = new QMediaRecorder(cameraAvant,this);
         recorder->setMuted(true);
         QVideoEncoderSettings settings = recorder->videoSettings();
         settings.setCodec("video/mpeg, mpegversion=(int)4, systemstream=(boolean)false");
           settings.setQuality(QMultimedia::NormalQuality);
           settings.setEncodingMode(QMultimedia::ConstantBitRateEncoding);
           recorder->setVideoSettings(settings);
         cameraAvant->start();
    

    void Rover::on_recording_start_clicked()
    {
    QString fileRecording=QDateTime::currentDateTime().toString(QString("'%1/RecordingVideo_'dd-MM-yyyy'_'hh:mm:ss'").arg(dossier));
    recorder->setOutputLocation(QUrl::fromLocalFile(filerecord));
    cameraAvant->setCaptureMode(QCamera::CaptureVideo);
    recorder->record();

    }
    void Rover::on_recording_stop_clicked()
    {
    recorder->stop();
    }

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #2

    @jack1998 said in QT's QMediaRecorder not working - Unable to record from camera:

    QFile file(fileRecording);

    How is anything attached to/writes to this local variable? That line does nothing.

    J 1 Reply Last reply
    1
    • JonBJ JonB

      @jack1998 said in QT's QMediaRecorder not working - Unable to record from camera:

      QFile file(fileRecording);

      How is anything attached to/writes to this local variable? That line does nothing.

      J Offline
      J Offline
      jack1998
      wrote on last edited by
      #3

      @JonB ok thank you for your reply but have you please any idea about the recording please ?

      J 1 Reply Last reply
      0
      • J jack1998

        @JonB ok thank you for your reply but have you please any idea about the recording please ?

        J Offline
        J Offline
        jack1998
        wrote on last edited by
        #4

        any idea please :(

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #5

          Hi,

          Did you check that "filerecord" points to a valid location ?
          Did you connect any of the error signals to know if something wrong happened ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 2 Replies Last reply
          0
          • SGaistS SGaist

            Hi,

            Did you check that "filerecord" points to a valid location ?
            Did you connect any of the error signals to know if something wrong happened ?

            J Offline
            J Offline
            jack1998
            wrote on last edited by jack1998
            #6

            @SGaist thank you for your reply, yes i can find the file video.PNG
            but i can't open it
            the error :
            AL lib: (EE) ALCcaptureAlsa_open: Could not open capture device 'default': Aucun fichier ou dossier de ce type
            QMediaRecorder::RecordingState
            QMediaRecorder::RecordingStatus
            QMediaRecorder::NoError
            CameraBin error: "Could not open device."
            CameraBin error: "Internal data stream error."

            J 1 Reply Last reply
            0
            • J jack1998

              @SGaist thank you for your reply, yes i can find the file video.PNG
              but i can't open it
              the error :
              AL lib: (EE) ALCcaptureAlsa_open: Could not open capture device 'default': Aucun fichier ou dossier de ce type
              QMediaRecorder::RecordingState
              QMediaRecorder::RecordingStatus
              QMediaRecorder::NoError
              CameraBin error: "Could not open device."
              CameraBin error: "Internal data stream error."

              J Offline
              J Offline
              jack1998
              wrote on last edited by
              #7
              This post is deleted!
              1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                Did you check that "filerecord" points to a valid location ?
                Did you connect any of the error signals to know if something wrong happened ?

                J Offline
                J Offline
                jack1998
                wrote on last edited by
                #8

                @SGaist what does that mean please AL lib: (EE) ALCcaptureAlsa_open: Could not open capture device 'default' please ?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  Did you check that you have access to the device(s) you are trying to use for recording ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  J 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Did you check that you have access to the device(s) you are trying to use for recording ?

                    J Offline
                    J Offline
                    jack1998
                    wrote on last edited by
                    #10

                    @SGaist how can i check them please ?

                    jsulmJ 1 Reply Last reply
                    0
                    • J jack1998

                      @SGaist how can i check them please ?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      @jack1998

                      ls -lh /dev/video4
                      

                      and see what user and groupd are set and also the access rights.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      J 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @jack1998

                        ls -lh /dev/video4
                        

                        and see what user and groupd are set and also the access rights.

                        J Offline
                        J Offline
                        jack1998
                        wrote on last edited by
                        #12

                        @jsulm hello thank you for your replay, i find this result with the terminal in raspberry: crw-rw----+ 1 root video 81, 17 mai 4 12:01 /dev/video4

                        jsulmJ 1 Reply Last reply
                        0
                        • J jack1998

                          @jsulm hello thank you for your replay, i find this result with the terminal in raspberry: crw-rw----+ 1 root video 81, 17 mai 4 12:01 /dev/video4

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          @jack1998 So, only root user and users which are member of the "video" group have access to /dev/video4
                          Is your user member of that group (enter this command in terminal to check: groups).

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          J 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @jack1998 So, only root user and users which are member of the "video" group have access to /dev/video4
                            Is your user member of that group (enter this command in terminal to check: groups).

                            J Offline
                            J Offline
                            jack1998
                            wrote on last edited by jack1998
                            #14

                            @jsulm thank you for your reply, i check it and i have access
                            it is not a problem with the code please?

                            J 1 Reply Last reply
                            0
                            • J jack1998

                              @jsulm thank you for your reply, i check it and i have access
                              it is not a problem with the code please?

                              J Offline
                              J Offline
                              jack1998
                              wrote on last edited by
                              #15

                              what does that mean please ?
                              GStreamer-CRITICAL **: 12:40:27.463:
                              Trying to dispose element camera_source, but it is in PAUSED instead of the NULL state.
                              You need to explicitly set elements to the NULL state before
                              dropping the final reference, to allow them to clean up.
                              This problem may also be caused by a refcounting bug in the
                              application or some element.
                              i m new with the qt :(

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #16

                                Are you able to use that device from GStreamer directly ?
                                Are there other applications trying to access it ?

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                J 1 Reply Last reply
                                0
                                • SGaistS SGaist

                                  Are you able to use that device from GStreamer directly ?
                                  Are there other applications trying to access it ?

                                  J Offline
                                  J Offline
                                  jack1998
                                  wrote on last edited by jack1998
                                  #17

                                  @SGaist AL lib: (EE) ALCcaptureAlsa_open: Could not open capture device 'default': no such file or folder

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • J jack1998

                                    @SGaist AL lib: (EE) ALCcaptureAlsa_open: Could not open capture device 'default': no such file or folder

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #18

                                    @jack1998 said in QT's QMediaRecorder not working - Unable to record from camera:

                                    AL lib: (EE) ALCcaptureAlsa_open: Could not open capture device 'default': no such file or folder

                                    Is this coming when you try to access the device directly using GStreamer?

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    J 1 Reply Last reply
                                    0
                                    • jsulmJ jsulm

                                      @jack1998 said in QT's QMediaRecorder not working - Unable to record from camera:

                                      AL lib: (EE) ALCcaptureAlsa_open: Could not open capture device 'default': no such file or folder

                                      Is this coming when you try to access the device directly using GStreamer?

                                      J Offline
                                      J Offline
                                      jack1998
                                      wrote on last edited by
                                      #19

                                      @jsulm yes

                                      J 1 Reply Last reply
                                      0
                                      • J jack1998

                                        @jsulm yes

                                        J Offline
                                        J Offline
                                        jack1998
                                        wrote on last edited by
                                        #20

                                        when I run the code in pi it works well however in root it does not work

                                        1 Reply Last reply
                                        0
                                        • SGaistS Offline
                                          SGaistS Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #21

                                          What do you mean by "in root" ?

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          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