Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-114558

QMediaRecorder crashes if computer screen is in portrait mode

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.6
    • 6.5.1
    • Multimedia
    • None
    • Windows

      When we try to record a screen that has its orientation changed to Portrait, the recording thread crashes. Here is a minimal example to reproduce the bug:

      #include <QApplication>
      
      #include <QMediaCaptureSession>
      #include <QScreenCapture>
      #include <QMediaRecorder>
      #include <QMediaFormat>
      #include <QUrl>
      
      #include <QTimer>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QMediaCaptureSession session;
      
          QScreenCapture screen;
          session.setScreenCapture(&screen);
          screen.setScreen(a.screens().at(1)); // <-- Change to the index of a rotated screen !!
          screen.start();
      
          QMediaRecorder recorder;
          session.setRecorder(&recorder);
      
          recorder.setOutputLocation(QUrl::fromLocalFile(a.applicationDirPath() +  "/x.mp4"));
      
          QTimer timer;
      
          int count = 0;
          QObject::connect(&timer, &QTimer::timeout, &a, [&]
          {
              qDebug() << ++count;
              if (count == 5)
              {
                  recorder.stop();
              }
              if (count == 10)
              {
                  a.quit();
              }
          });
      
          timer.start(1000);
      
          return a.exec();
      }
      

      Sometimes it's possible to get a very short recording, but the result is like this:

        1. screenshot-1.png
          113 kB
          Carlos Eduardo Gesser
        2. x.mp4
          272 kB
          Carlos Eduardo Gesser
        3. screenshot-2.png
          761 kB
          Carlos Eduardo Gesser
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            johanseg Jøger Hansegård
            cegesser Carlos Eduardo Gesser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes