3

I have an issue where a video is played in the correct 16:9 aspect ratio when played through VLC or quicktime player, but when I attempt to extract individual frames with ffmpeg the frames come out as 4:3 aspect ratio.

The ffprobe output on the video in question is as follows

$ ffprobe -v error -select_streams v:0 -show_entries stream -of default=noprint_wrappers=1 -print_format json movie.mp4

{
"programs": [

],
"streams": [
    {
        "index": 0,
        "codec_name": "h264",
        "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
        "profile": "Main",
        "codec_type": "video",
        "codec_time_base": "126669/6400000",
        "codec_tag_string": "avc1",
        "codec_tag": "0x31637661",
        "width": 2592,
        "height": 1944,
        "coded_width": 2592,
        "coded_height": 1944,
        "has_b_frames": 0,
        "sample_aspect_ratio": "4:3",
        "display_aspect_ratio": "16:9",
        "pix_fmt": "yuvj420p",
        "level": 50,
        "color_range": "pc",
        "color_space": "bt709",
        "color_transfer": "bt709",
        "color_primaries": "bt709",
        "chroma_location": "left",
        "refs": 1,
        "is_avc": "true",
        "nal_length_size": "4",
        "r_frame_rate": "25/1",
        "avg_frame_rate": "3200000/126669",
        "time_base": "1/12800",
        "start_pts": 0,
        "start_time": "0.000000",
        "duration_ts": 126682,
        "duration": "9.897031",
        "bit_rate": "4638928",
        "bits_per_raw_sample": "8",
        "nb_frames": "250",
        "disposition": {
            "default": 1,
            "dub": 0,
            "original": 0,
            "comment": 0,
            "lyrics": 0,
            "karaoke": 0,
            "forced": 0,
            "hearing_impaired": 0,
            "visual_impaired": 0,
            "clean_effects": 0,
            "attached_pic": 0,
            "timed_thumbnails": 0
        },
        "tags": {
            "language": "und",
            "handler_name": "VideoHandler"
        }
    }
]
}

So it says

    "width": 2592,
    "height": 1944,
    "coded_width": 2592,
    "coded_height": 1944,
    "has_b_frames": 0,
    "sample_aspect_ratio": "4:3",
    "display_aspect_ratio": "16:9",

which seems odd to me. The width/height are in 4:3, the sample aspect ratio is 4:3, the display is 16:9?

Now, when I play this through VLC/Quicktime the video looks fine (screenshot below)

enter image description here

but now, if I run an ffmpeg command to extract individual frames from this video, they come out in 4:3

ffmpeg -y -hide_banner -nostats -loglevel error -i movie.mp4 -vf select='eq(n\,10)+eq(n\,20)+eq(n\,30)+eq(n\,40)',scale=-1:640 -vsync 0 /tmp/ffmpeg_image_%04d.jpg

enter image description here

So I guess my questions are as follows:

  1. what is the relation between display aspect ratio, sample aspect ratio, and the width/height ratio?
  2. how to I get ffmpeg to output in the correct aspect ratio?
John Allard
  • 3,564
  • 5
  • 23
  • 42
  • Essentially a duplicate, with one difference being that many image formats don't save SAR so that the scaling has to be `scale=oh*dar:640` in your case. – Gyan Jun 18 '18 at 19:28

0 Answers0