Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 44213/4a9530ff042280b3d2d63631545bd7b1 to your computer and use it in GitHub Desktop.
Save 44213/4a9530ff042280b3d2d63631545bd7b1 to your computer and use it in GitHub Desktop.
ffmpeg cheat sheet
ffmpeg Cheat Sheet
-------------------------------------------
Lossless x264 compression:
ffmpeg -i capture1.00.avi -c:v libx264 -preset veryslow -crf 0 -c:a flac -compression_level 12 capture1.mkv
Lossless x265 compression:
ffmpeg -i capture1.00.avi -c:v libx265 -preset veryslow -x265-params lossless=1 -c:a flac -compression_level 12 capture1.mkv
Lossless compress audio in a video file:
ffmpeg -i capture1.00.avi -c:v copy -c:a flac -compression_level 12 capture1.mkv
Cutting file:
ffmpeg -i input.mp4 -ss 01:10:27 -to 02:18:51 -c:v copy -c:a copy output.mp4
ffmpeg -i input.mp4 -ss 01:10:27 -t 01:00:00 -c:v copy -c:a copy output.mp4
Concat files:
ffmpeg -i input-1.mkv -i input-2.avi -filter_complex "[0:v] [0:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -c:v libx264 -preset veryslow -crf 0 -c:a flac -compression_level 12 concat_video.mkv
Extract audio to an m4a container:
ffmpeg -i "01 - Marillion - Go!.mka" -c:a copy go.m4a
Transcoding to VP9:
ffmpeg -i "file.wmv" -c:v libvpx-vp9 -crf 24 -threads 2 -b:v 0 -c:a libopus -b:a 96k test-2.mkv
Upscale video:
ffmpeg -i input.mp4 -vf scale=1920x1080:flags=lanczos -c:v libx264 -crf 0 -c:a copy output_compress_1080p.mp4
Extract front channels audio:
ffmpeg -i 6channels.wav -af "pan=stereo|c0=FL|c1=FR" stereo.wav
Mixdown audio to stereo:
ffmpeg -i 6channels.wav -ac 2 stereo.wav
mkvtoolnix Commands
-------------------------------------------
Setting Aspect Ratio:
mkvpropedit.exe messing.about.with.camera.mkv -e track:1 -s display-unit=3 -s display-width=4 -s display-height=3
Batch Commands
-------------------------------------------
FOR /F "tokens=*" %G IN ('dir /b *.flac') DO ffmpeg -i "%G" -acodec mp3 "%~nG.mp3"
FOR /F "tokens=*" %G IN ('dir /b *.mka') DO ffmpeg -i "%G" -map_chapters -1 -c:a copy "%~nG.m4a"
References
-------------------------------------------
VP9 Encoding guide: http://wiki.webmproject.org/ffmpeg/vp9-encoding-guide
Google Recommended VP9 Settings: https://developers.google.com/media/vp9/settings/vod
Multi-thread Encoding: https://stackoverflow.com/questions/41372045/vp9-encoding-limited-to-4-threads
FFMpeg Audio Channel Extraction: https://trac.ffmpeg.org/wiki/AudioChannelManipulation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment