Skip to content

Instantly share code, notes, and snippets.

@devhero
Last active January 19, 2023 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devhero/51345fd905951c59cfc8ffe42c6830f9 to your computer and use it in GitHub Desktop.
Save devhero/51345fd905951c59cfc8ffe42c6830f9 to your computer and use it in GitHub Desktop.
ffmpeg cookbook
# rotate
ffmpeg -i input.mp4 -map_metadata 0 -c copy -metadata:s:v rotate="180" output.mp4
# extract subs from mp4
# https://superuser.com/questions/393762/how-to-extract-subtitles-from-mp4-and-mkv-movies
ffmpeg -i video.mp4 subtitle.srt
# convert audio (using vbr)
ffmpeg -i input.mkv -c:a libopus -b:a 256k -vbr 1 -af "channelmap=channel_layout=5.1" output.mkv
# use still image instead of video and convert audio
ffmpeg -loop 1 -i image.jpg -i input.mkv -c:v libx264 -tune stillimage -c:a libopus -b:a 256k -pix_fmt yuv420p -shortest output.mkv
# Speeding up/slowing down audio
# You can speed up or slow down audio with the ​atempo audio filter. To double the speed of audio:
ffmpeg -i input.mkv -filter:a "atempo=2.0" -vn output.mkv
# Change audio speed converting to opus 256k
ffmpeg -i input.mkv -c:a libopus -b:a 256k -af "channelmap=channel_layout=5.1, atempo=2.0" -vn output.mkv
# convert tempo from 25fps to 23.976fps (23,976/25 = 0,95904)
# [optional] convert with codec Opus, 224kbps VBR, 5.1 channels
ffmpeg -i input.mkv -c:a libopus -b:a 224k -vbr 1 -af "channelmap=channel_layout=5.1,rubberband=tempo=0.95904" -vn out.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment