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

Incorrect frame rate selectiion for QCamera on iOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.8.0 FF
    • 6.6.2
    • Multimedia
    • None
    • iOS/tvOS/watchOS
    • b8047fbd7 (dev)
    • Multimedia wk 15-16

    Description

      Per the QCameraFormat docs, "the camera will always try to use the highest frame rate supported by a certain video format." However, the code used to select the frame rate pick the first match it finds, rather than the best match. For example, when requesting a 240 fps camera on iOS, I get a 60 fps camera, since 60 fps is with the bounds specified by the [minFrameRate, maxFrameRate] request of [2, 240].

      The current code, in qtmultimedia/src/plugins/multimedia/darwin/camera.avfcamerautility.mm line 125:]

       

      {{ if (frameRateRange.minFrameRate >= cameraFormatPrivate->minFrameRate
      && frameRateRange.maxFrameRate <= cameraFormatPrivate->maxFrameRate) {}}

            {{ newFormat = format;}}

             {{ break;}}

      {} }{}{}

      Note that this picks the first match, not the best match. My revised code:

      {{   AVCaptureDeviceFormat *newFormat = nil;
          qreal newFormatMaxFrameRate = 0;
          NSArray<AVCaptureDeviceFormat *> *formats = captureDevice.formats;
          for (AVCaptureDeviceFormat *format in formats) {
              CMFormatDescriptionRef formatDesc = format.formatDescription;
              CMVideoDimensions dim = CMVideoFormatDescriptionGetDimensions(formatDesc);
              FourCharCode cvPixFormat = CMVideoFormatDescriptionGetCodecType(formatDesc);

              if (requiredCvPixFormat == cvPixFormat
                  && cameraFormatPrivate->resolution == QSize(dim.width, dim.height)
                  && (!cvFormatValidator || cvFormatValidator(cvPixFormat))) {
                  for (AVFrameRateRange *frameRateRange in format.videoSupportedFrameRateRanges) {
                      if (frameRateRange.minFrameRate >= cameraFormatPrivate->minFrameRate
                          && frameRateRange.maxFrameRate <= cameraFormatPrivate->maxFrameRate
                          && (newFormat == nil || newFormatMaxFrameRate < frameRateRange.maxFrameRate))

      {                     newFormat = format;                     newFormatMaxFrameRate = frameRateRange.maxFrameRate;                 }

                  }
              }}}

       

      Note that this source file does contain a qt_find_best_framerate_match function that might be helpful.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            bjones Bryan Jones
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There is 1 open Gerrit change