Skip to content

Instantly share code, notes, and snippets.

@jahed
Last active May 28, 2023 17:54
Show Gist options
  • Save jahed/b413f6d40c24da5d528dd6a98d7a2043 to your computer and use it in GitHub Desktop.
Save jahed/b413f6d40c24da5d528dd6a98d7a2043 to your computer and use it in GitHub Desktop.
FFMPEG Tricks

FFMPEG Tricks

Merging Multiple Audio Tracks

Useful for gamerips where music is split into multiple tracks for dynamic mixes and need to be merged together for a true track.

amerge is more flexible than amix so prefer using amerge.

-ac is to set the number of audio channels (e.g. -ac 2 for stereo)

ffmpeg -i layer-1.ogg -i layer-2.ogg -filter_complex amerge=inputs=2 -ac 2 output.mp3

Video to GIF

ffmpeg -i video.mp4 -vf "fps=10,scale=800:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 video.gif

Resize Video

Add the following to the command and adjust as needing. scale=<width>:<height> where -1 automatically sets the value to maintain aspect ratio.

 -filter:v scale=1280:-1 -c:a copy

Remove Audio

Add the following to the command.

-an
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment