Skip to content

Instantly share code, notes, and snippets.

@msultan
Forked from mpharrigan/1-ffmpeg.sh
Created November 23, 2015 23:16
Show Gist options
  • Save msultan/e7a1623ac4994e82cf50 to your computer and use it in GitHub Desktop.
Save msultan/e7a1623ac4994e82cf50 to your computer and use it in GitHub Desktop.
Make a quality movie using ffmpeg
ffmpeg -i molecule.%5d.ppm -c:v libx264 -preset slow -crf 18 molecule.mkv
# -i input filenames
# -c:v codec (libx264 --> H.264)
# -preset duh
# -crf quality factor, lower = better, 18 = practically lossless
# output filename
# For colors, make sure you're using yuv444 which should be the default in newer ffmpeg
# Note: you can use either the vmd ppm or tga image files
ffmpeg \
-framerate 90 -i vmd/final.molecule.%05d.tga \
-framerate 90 -i plot/frame%05d.png \
-c:v libx264 \
-preset slow \
-crf 18 \
-filter_complex "\
[1:v] scale=in_w*0.8:in_h*0.8 [sclvrl] ;\
[0:v][sclvrl] overlay=eval='init':x=W-w-5:y=5 [overout] ;\
[overout] scale=trunc(in_w/2)*2:trunc(in_h/2)*2" \
movie.overlay.mkv
# syntax for ffmpeg "filters" is
# [in_stream_name] command=parameter1=value1:parameter2=value2 [out_stream_name] ;
#
# The above takes video stream 1 [1:v] and scales it by 0.8
# It then overlays the output of that [sclvr1] onto the vmd movie [0:v]
# The final line rounds the whole video to have a width and height divisible
# by 2, which is something needed by h264 (??). I think the default width for
# vmd is an odd number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment