Skip to content

Instantly share code, notes, and snippets.

@boblemarin
Last active November 16, 2021 15:19
Show Gist options
  • Save boblemarin/623d4af4902855f1e8c7d2604f61bc50 to your computer and use it in GitHub Desktop.
Save boblemarin/623d4af4902855f1e8c7d2604f61bc50 to your computer and use it in GitHub Desktop.
FFMPEG Cheat Sheet

FFMPEG - AV files manipulation

FFMPEG: extraire (sans ré-encodage) 5s à partir de 30s

ffmpeg -ss 00:00:30 -i input.mp4 -t 00:00:05 -vcodec copy -acodec copy output.mp4

jusque la fin:

ffmpeg -ss 01:14:00 -i input.mp4 -vcodec copy -acodec copy output.mp4

FFMPEG: merge audio + video

ffmpeg -i input.mp4 -i audio.m4a -c copy output.mp4

FFMpeg: extract audio from video (no-reencoding)

ffmpeg -i input.avi -vn -acodec copy output.wav

encode mp3 at 320kbps (-c:a = codec:audio, -q:a = quality audio - lower is better)

ffmpeg -i input.wav -c:a libmp3lame -q:a 0 output.mp3

encode all wave/flac files in folder at 320kbps

for i in *.wav; do ffmpeg -i "$i" -c:a libmp3lame -q:a 0 "${i%.*}.mp3"; done

for i in *.flac; do ffmpeg -i "$i" -c:a libmp3lame -q:a 0 "${i%.*}.mp3"; done

convert video to image sequence

ffmpeg -i in.mp4 -vf fps=1 -vsync 0 out%d.png

ffmpeg -i in.mp4 -vf fps=1,select='between(t,2,6)+between(t,15,24)' -vsync 0 out%d.png

convert image sequence to video (4fps in this case)

ffmpeg -framerate 30 -pattern_type glob -i '*.png' -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

concatenate multiple video files into one

ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4

files.txt content :

file 'video1.mp4'
file 'video2.mp4'
file 'video3.mp4'

delay audio by 350ms in video file

ffmpeg -i "input.mkv" -itsoffset 0.35 -i "input.mkv" -map 0:v -map 1:a -c copy "output.mkv"

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