ffmpeg 获取方向反转

标签 ffmpeg ffprobe

我获得了视频的分辨率,但 ffmpeg/ffprobe 正在反转。最大的数字始终是宽度。

我的意思是,不管我得到的是垂直还是水平视频的分辨率,我总是得到 640x480,而它应该是 480x640。我还尝试将宽高比设置为 4:3 而不是 3:4

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

所以我的问题是如何获得正确的分辨率或至少我需要知道视频是水平还是垂直的方向。

查看完整回复:

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

但这是视频的样子 enter image description here

最佳答案

ffprobe 正在报告实际宽度 x 高度。首先显示宽度,然后显示高度(无论您要求的顺序如何)。您的播放器正在使用旋转元数据或显示矩阵端数据并在播放时旋转。

您可以使用 ffprobe 来显示旋转并使用它来确定显示的宽度 x 高度。在此示例中,它的宽度为 1920,高度为 1080,视频旋转 270 度后显示为 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

关于ffmpeg 获取方向反转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53339787/

相关文章:

Python .avi 到 .mp4

python - FFMPEG python检查字典键是否存在

ffmpeg - 如何使用 ffprobe 检测带有 pts 图像的 pts scte35 消息 I

audio - 错误 : Argument 'Creation]/audio_section_working/1.mp3' provided as input filename, 但已指定 '/e/[Content'

python - 使用 ctypes 调用 FFmpeg 库时如何指定非默认类型

command-line - 如何将一系列图像转换为文件名不是从 1 开始的电影?

video - 将 .ass (ssa, aegisub) SubStationAlpha subs 添加到 mp4 的最快方法?

c++ - 问题: FFMPEG seeking with av_seek_frame using byte positions

ffmpeg - 如何使用 FFProbe 检测变形视频?

java - FFmpeg 错误代码 254