Search code examples
ffmpegmp4h.264mov

FFMPEG options differences between two videos


So I'm working with a video build out of pngs. Making a video hasn't been too hard thanks to ffmpeg however most of the videos I've made work great playing forward and are extremely choppy playing backwards.

Using a program named MPEG Streamclip plus Handbrake I managed to convert my video to one that plays great forward and backward. But now I can't figure out how to pass in the right options to ffmpeg to replicate this video.

Using ffprobe I have some outputs of the good and bad video. What options am I missing?

Bad Video:

$ ffprobe tea_ffmpeg.mov 
ffprobe version 3.0 Copyright (c) 2007-2016 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'tea_ffmpeg.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf57.25.100
  Duration: 00:00:08.04, start: 0.000000, bitrate: 1140 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 676x450 [SAR 675:676 DAR 3:2], 1138 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : Lavc57.24.102 libx264

Good Video:

$ ffprobe test.mov 
ffprobe version 3.0 Copyright (c) 2007-2016 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda
  libavutil      55. 17.103 / 55. 17.103
  libavcodec     57. 24.102 / 57. 24.102
  libavformat    57. 25.100 / 57. 25.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 31.100 /  6. 31.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2016-03-09 15:16:37
  Duration: 00:00:08.04, start: 0.000000, bitrate: 2650 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 674x450, 2646 kb/s, 25 fps, 25 tbr, 25k tbn, 50k tbc (default)
    Metadata:
      creation_time   : 2016-03-09 15:16:47
      handler_name    : Apple Alias Data Handler
      encoder         : H.264

FFMPEG Command so far:

ffmpeg -y -i 'pngs/tea-%03d.png' -vf scale=674:-2  -vcodec libx264 -pix_fmt yuv420p -r 25 tea_ffmpeg.mov

I understand mov vs mp4 should just be a container spec, but mov was the first I got working. I'm more than happy to use mp4.


Solution

  • The main thing that stands out is the profile. So,

    ffmpeg -y -i 'pngs/tea-%03d.png' -vf scale=674:-2  -vcodec libx264 -profile:v main -pix_fmt yuv420p -r 25 tea_ffmpeg.mov
    

    To be safer, you can use baseline profile and small GOP sizes (at some cost to file size)

    ffmpeg -y -i 'pngs/tea-%03d.png' -vf scale=674:-2  -vcodec libx264 -profile:v baseline -g 12 -pix_fmt yuv420p -r 25 tea_ffmpeg.mov