ffmpegquicktime

Can't open ffmpeg output with quicktime, pix_fmt flag doesn't fix it


Quicktime can't read the output of ffmpeg when I try making an animation. It uploads to imgur and plays no problem. A previous thread recommended that I add the -pix_fmt yuv420p flag. But, on my system, that does not work. ffmpeg runs without error when I exclude the pix_fmt flag, but I cannot open the output animation in quicktime.

Why won't quicktime open the animation? How can I make the animation open with quicktime?

$ ffmpeg -y -i animation/tigers_${ii}_%05d.png  -pix_fmt yuv420p tiger${ii}.mp4
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, image2, from 'animation/tigers_1.10_%05d.png':
  Duration: 00:00:08.32, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba(pc), 2023x3036 [SAR 17716:17716 DAR 2023:3036], 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x7fdd7b800c00] width not divisible by 2 (2023x3036)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

Solution

  • The error is clear,

    [libx264 @ 0x7fdd7b800c00] width not divisible by 2 (2023x3036)
    

    Use the crop filter to get rid of one column of pixels:

    ffmpeg -y -i animation/tigers_${ii}_%05d.png -vf "crop='iw-mod(iw,2)':'ih-mod(ih,2)',format=yuv420p" tiger${ii}.mp4
    

    The -pix_fmt option is equivalent to adding the format filter as the last filter.