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. How to change format of output video file in videoRecorder?
Forum Updated to NodeBB v4.3 + New Features

How to change format of output video file in videoRecorder?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 7 Posters 992 Views 2 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.
  • R Offline
    R Offline
    r3d9u11
    wrote on 9 Aug 2019, 12:27 last edited by
    #1

    Hi. Is it possible to record video from camera to a specified format like "mkv" or "avi"?
    By default videoRecorder uses "ogg" and chagings of settings doesn't any effect.
    For example:

    videoRecorder {
    ...
    videoCodec: "h264"
    mediaContainer: "mkv"
    outputLocation: "/home/user/record.mkv"
    ...
    }
    

    will write file "/home/user/record.mkv.ogg"

    What I'm doing wrong?

    Thanks!

    P A 2 Replies Last reply 9 Aug 2019, 13:44
    0
    • R r3d9u11
      9 Aug 2019, 12:27

      Hi. Is it possible to record video from camera to a specified format like "mkv" or "avi"?
      By default videoRecorder uses "ogg" and chagings of settings doesn't any effect.
      For example:

      videoRecorder {
      ...
      videoCodec: "h264"
      mediaContainer: "mkv"
      outputLocation: "/home/user/record.mkv"
      ...
      }
      

      will write file "/home/user/record.mkv.ogg"

      What I'm doing wrong?

      Thanks!

      P Offline
      P Offline
      Pablo J. Rogina
      wrote on 9 Aug 2019, 13:44 last edited by
      #2

      @r3d9u11 checking documentation for CameraRecorder QML Type says:

      CameraRecorder allows recording camera streams to files, and adjusting recording settings and metadata for videos.

      It should not be constructed separately, instead the videoRecorder property of a Camera should be used.

      See the example snippet shown there...

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      R 1 Reply Last reply 9 Aug 2019, 14:38
      1
      • P Pablo J. Rogina
        9 Aug 2019, 13:44

        @r3d9u11 checking documentation for CameraRecorder QML Type says:

        CameraRecorder allows recording camera streams to files, and adjusting recording settings and metadata for videos.

        It should not be constructed separately, instead the videoRecorder property of a Camera should be used.

        See the example snippet shown there...

        R Offline
        R Offline
        r3d9u11
        wrote on 9 Aug 2019, 14:38 last edited by r3d9u11 8 Sept 2019, 14:55
        #3

        @pablo-j-rogina I'm sorry for my incomplete example
        Sure, I defined videoRecorder inside the Camera object:

        Camera {
            id: camera
            deviceId: QtMultimedia.availableCameras[0].deviceId
            captureMode: Camera.CaptureVideo
        
            onError: {
                if (Camera.NoError !== error) {
                    console.log("[qmlvideo] CameraItem.onError error " + error + " errorString " + errorString)
                }
            }
        
            videoRecorder {
                muted: true
                videoCodec: "h264"
                mediaContainer: "mp4"
                videoRecorder.outputLocation: "/home/user/Desktop/record-1.mp4"
                
                onRecorderStateChanged: {
                    if (camera.videoRecorder.recorderState == CameraRecorder.RecordingState) {
                        console.log("recording to: " + camera.videoRecorder.outputLocation)
                    }
                    else if (camera.videoRecorder.recorderState == CameraRecorder.StoppedState) {
                        console.log("saved to: " + camera.videoRecorder.outputLocation)
                    }
                }
            }
        }
        

        I changed it:

        Camera {
            id: camera
            deviceId: QtMultimedia.availableCameras[0].deviceId
            captureMode: Camera.CaptureVideo
        
            onError: {
                if (Camera.NoError !== error) {
                    console.log("[qmlvideo] CameraItem.onError error " + error + " errorString " + errorString)
                }
            }
        
            videoRecorder.muted: true
            videoRecorder.videoCodec: "h264"
            videoRecorder.mediaContainer: "mp4"
            videoRecorder.outputLocation: "/home/user/Desktop/record-1.mp4"
            
            videoRecorder.onRecorderStateChanged: {
                if (camera.videoRecorder.recorderState == CameraRecorder.RecordingState) {
                    console.log("recording to: " + camera.videoRecorder.outputLocation)
                }
                else if (camera.videoRecorder.recorderState == CameraRecorder.StoppedState) {
                    console.log("saved to: " + camera.videoRecorder.outputLocation)
                }
            }
        }
        

        And nothing changed, still .ogg files in output.
        Both samples will write file /home/user/Desktop/record-1.mp4.ogg

        Same situation with any other extensions (e.g. mkv).
        Also same situation with image capturing (recorder will write images to *.ogg files, too).

        I'm on Qt 5.9.8

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Aug 2019, 18:18 last edited by
          #4

          Hi,

          Might be a silly question but do you have a matroska codec available for your system ?

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

          R 1 Reply Last reply 15 Aug 2019, 11:02
          0
          • S SGaist
            9 Aug 2019, 18:18

            Hi,

            Might be a silly question but do you have a matroska codec available for your system ?

            R Offline
            R Offline
            r3d9u11
            wrote on 15 Aug 2019, 11:02 last edited by r3d9u11
            #5

            @sgaist Yes, I think. I can watch mkv files via VLC without any troubles, for example.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 15 Aug 2019, 16:16 last edited by
              #6

              The fact that VLC can play the file has no role here. VLC doesn't use the system backend. However, QtMultimedia uses the system backend hence my question about having a codec on your system.

              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
              1
              • R r3d9u11
                9 Aug 2019, 12:27

                Hi. Is it possible to record video from camera to a specified format like "mkv" or "avi"?
                By default videoRecorder uses "ogg" and chagings of settings doesn't any effect.
                For example:

                videoRecorder {
                ...
                videoCodec: "h264"
                mediaContainer: "mkv"
                outputLocation: "/home/user/record.mkv"
                ...
                }
                

                will write file "/home/user/record.mkv.ogg"

                What I'm doing wrong?

                Thanks!

                A Offline
                A Offline
                anil_arise
                wrote on 17 Aug 2019, 10:59 last edited by
                #7

                @r3d9u11 you need to check :

                1. supportedVideoCodecs
                2. supportedContainers

                according that set your QVideoEncoderSettings for mediarecorder

                1 Reply Last reply
                2
                • P Offline
                  P Offline
                  phyllidaverdiguel70
                  wrote on 19 Apr 2022, 08:33 last edited by
                  #8

                  guys, did you finally understand how to do it or not?

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    raoulfreudenbergtrp
                    Banned
                    wrote on 19 Apr 2022, 08:48 last edited by raoulfreudenbergtrp
                    #9
                    This post is deleted!
                    jsulmJ 1 Reply Last reply 19 Apr 2022, 08:50
                    0
                    • R raoulfreudenbergtrp
                      19 Apr 2022, 08:48

                      This post is deleted!

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 19 Apr 2022, 08:50 last edited by
                      #10

                      @raoulfreudenbergtrp Maybe. If you provide more details and the code...

                      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