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. Problem detecting video codecs using QMediaRecorder

Problem detecting video codecs using QMediaRecorder

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmediarecordercodec
5 Posts 2 Posters 664 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.
  • OlivierDuguayO Offline
    OlivierDuguayO Offline
    OlivierDuguay
    wrote on last edited by
    #1

    Hi, I have simple problem but doesn't seems to find any solution to it.

    I'm trying to create a video recorder by connecting to a camera using QCamera, QCameraInfo, QCameraViewfinder etc.
    I was able to get the camera to work, I see the live video feed of my camera without any problem.

    Now, I want to record this live feed to a .mp4 file (or any other format) but when creating a QMediaRecorder, I tried to use the QMediaRecorder::supportedVideoCodecs() functions to get the available video codecs, but it always return an empty list. I have VLC installed on the computer, FFmpeg as well (the FFmpeg is also included in the project as a library but still, QMediaRecorder never find any codecs.)

    const QList<QCameraInfo> availableCameras = QCameraInfo::availableCameras();
        if(!availableCameras.isEmpty()){
            /* Create a camera with info */
            m_camera.reset(new QCamera(availableCameras.first()));
            m_camera->setCaptureMode(QCamera::CaptureVideo);
            m_camera->setViewfinder(ui->viewfinder);
            m_camera->start();
    
            /* Create media recorder */
            m_mediaRecorder.reset(new QMediaRecorder(m_camera.data()));
            m_mediaRecorder->setMetaData(QMediaMetaData::Title, QVariant(QLatin1String("Video Title Test")));
    
            QList<QCameraViewfinderSettings> viewFinderSettingsList = m_camera->supportedViewfinderSettings();
            m_camera->setViewfinderSettings(viewFinderSettingsList.first());
            m_camera->start();
    
            QVideoEncoderSettings videoSettings = m_mediaRecorder->videoSettings();
            QStringList supportedVideoCodecs =  m_mediaRecorder->supportedVideoCodecs();
            // ...
            // Code continue here but since the list is empty at this point, it ain't revelant for the problem
    }
    

    Is there any thing I forgot to include ...

    #include <QCamera>
    #include <QCameraInfo>
    #include <QMediaMetaData>
    #include <QMediaRecorder>
    

    I used those configurations in the .pro file :

    QT       += core gui network multimedia multimediawidgets
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++17
    

    Thanks in advance for any hints you could give me !

    Olivier Duguay

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

      Hi,

      What OS are you running ?

      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
      • OlivierDuguayO Offline
        OlivierDuguayO Offline
        OlivierDuguay
        wrote on last edited by
        #3

        Microsoft Windows 10 Pro
        Version 10.0.18363 Build 18363
        x64-based PC
        Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz, 3408Mhz, 4 Core(s), 8 Logical Processor(s)
        16 GB of Installed Physical Memory (RAM)
        System manufacturer : HP

        Olivier Duguay

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

          In that case, the fact that ffmpeg and VLC are installed does not matter as they don't provide system codecs and Qt uses the native backend.

          You'll have to install some other codec packages although I am surprised that you don't even have access to the classic AVI stuff.

          Note that you can also use VLC in your application. They provide Qt wrappers.

          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
          • OlivierDuguayO Offline
            OlivierDuguayO Offline
            OlivierDuguay
            wrote on last edited by
            #5

            I'm as surprised as you that I don't have at least one codec... I'll try installing other codecs packages and have a look at VLC's Qt Wrapper but I mainly choose to use QMediaRecorder to reduce any other inclusion of librairies.

            Thanks for the info, I'll keep you up-to-date.

            Olivier Duguay

            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