3

I getting the resolution for a video, but ffmpeg/ffprobe is getting inverted.. Always the biggest number is the width.

I mean, it doesn't matter if I'm getting the resolution of a vertical or horizontal video, I'm always getting for example 640x480 when it should be 480x640. Also I tried with the aspect ratio as 4:3 instead of 3:4

ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 original.mp4

So my question is how I can get the right resolution or at least the orientation I need to know if the video is horizontal or vertical.

See full response:

ffprobe -select_streams v:0 -show_entries stream=width,height -of csv=p=0 original.mp4
ffprobe version N-86781-gd8f1982639-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-11) 20170519
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      55. 67.100 / 55. 67.100
  libavcodec     57.100.104 / 57.100.104
  libavformat    57. 75.100 / 57. 75.100
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 95.100 /  6. 95.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
  libpostproc    54.  6.100 / 54.  6.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x4ff7e60] sample aspect ratio already set to 1:1, ignoring 'pasp' atom (65536:65536)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'original.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2018-11-12T22:15:04.000000Z
    com.android.version: 7.0
  Duration: 00:01:10.30, start: 0.000000, bitrate: 9497 kb/s
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m), 1280x720, 9365 kb/s, SAR 1:1 DAR 16:9, 23.97 fps, 24 tbr, 90k tbn, 180k tbc (default)
    Metadata:
      rotate          : 270
      creation_time   : 2018-11-12T22:15:04.000000Z
      handler_name    : VideoHandle
    Side data:
      displaymatrix: rotation of 90.00 degrees
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2018-11-12T22:15:04.000000Z
      handler_name    : SoundHandle
1280,720

but this is the appearance of the video enter image description here

Faabass
  • 1,394
  • 8
  • 29
  • 58

1 Answers1

2

ffprobe is reporting the actual width x height. Width is displayed first, then height (no matter the order you request it). Your player is using the rotate metadata or the displaymatrix side data and rotating upon playback.

You can use ffprobe to display the rotation and use that to determine the displayed width x height. In this example it has a width of 1920, a height of 1080, and the video is rotated 270 degrees which displays as 1080x1920.

$ ffprobe -v error -select_streams v:0 -show_entries stream=width,height:stream_tags=rotate -of csv=p=0 input.mp4
1920,1080,270
llogan
  • 121,796
  • 28
  • 232
  • 243