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 find QMediaPlayer Video Resolution and Aspect Ratio
Qt 6.11 is out! See what's new in the release blog

How to find QMediaPlayer Video Resolution and Aspect Ratio

Scheduled Pinned Locked Moved General and Desktop
qmediaplayervideoqtcreator
3 Posts 2 Posters 3.1k 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.
  • P Offline
    P Offline
    Paul S131
    wrote on last edited by
    #1

    This seems too simple, I must be overlooking something?

    How do I find the native video size or aspect ratio from a video file being displayed by a QMediaPlayer?

    The video Resolution, PixelAspectRatio, etc., should be in the MetaData, but I wait for MetaData Update Signals, and wait for seconds after the video .play()s, but isMetaDataAvailable() always returns false, and .availableMetaData() and .metaData(QMediaMetaData::Resolution).toSize() always return empty.

    There seems to be nowhere else to get the video resolution information, or am I missing something?

    I can open the video, play the video at full screen, etc.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      You may try to use QMediaPlayer::media() to get QMediaContent and then get a list of QMediaResources. The media resource should contain resolution data if it is available from a stream or a file.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Paul S131
        wrote on last edited by
        #3

        I tried the suggestion from andreyc using QMediaPlayer::media() - which did not work. The QMediaResources had information like URL (localFile name), but the resolution data returned 0 (unknown).

        I did find an answer at http://forum.qt.io/topic/31278/solved-get-resolution-of-a-video-file-40-qmediaplayer-41/2, using QGraphicsVideoItems class property: nativeSize after the video started playing. (Note here - need to wait for the video to actually load & play after calling QMediaPlayer::play(). )

        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