Skip to content

Instantly share code, notes, and snippets.

@WANGJIEKE
Last active January 27, 2023 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WANGJIEKE/171eb76c697cfd384c3b3d066ca0c172 to your computer and use it in GitHub Desktop.
Save WANGJIEKE/171eb76c697cfd384c3b3d066ca0c172 to your computer and use it in GitHub Desktop.
My FFmpeg Command Collection
# Source: https://stackoverflow.com/a/59307017
# Merge two audio track into one
ffmpeg -i originalfile.mov -c:v copy -c:a aac -b:a 160k -ac 2 -filter_complex amerge=inputs=2 output.mp4
# Source: https://stackoverflow.com/a/36120894
# Get last x second
ffmpeg -sseof -10 -i input.mp4 output.mp4
# Source: https://superuser.com/a/933310
# Reduce file size
ffmpeg -i input.avi -c:v libx264 -crf 18 -preset veryslow -c:a copy out.mp4
# Source: https://stackoverflow.com/questions/9913032/how-can-i-extract-audio-from-video-with-ffmpeg
# Extract audio to a separate file
ffmpeg -i input-video.avi -vn -acodec copy output-audio.aac
ffmpeg -i sample.avi -q:a 0 -map a sample.mp3 # re-encoding with mp3
# Change audio sample rate and normalize its volume
# https://superuser.com/questions/323119/how-can-i-normalize-audio-using-ffmpeg
# https://superuser.com/questions/253467/convert-an-mp3-from-48000-to-44100-hz
ffmpeg -i video-in -ar 48000 -filter:a loudnorm -vcodec copy video-out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment