Skip to content

Instantly share code, notes, and snippets.

@mayazdi
Last active August 13, 2024 06:32
Show Gist options
  • Save mayazdi/9c3fc4f6e9828a803be757d177cea8e1 to your computer and use it in GitHub Desktop.
Save mayazdi/9c3fc4f6e9828a803be757d177cea8e1 to your computer and use it in GitHub Desktop.
ffmpeg useful commands

ffmpeg commands

reduce video size

ffmpeg -i input.mp4 -b 40k output.mp4

merge video and audio into one file

ffmpeg -i video.mp4 -i audio.m4a -c copy -map 0:v -map 1:a output.mp4

Above is preferred (fast without re-encoding)

ffmpeg -i video.mp4 -i audio.mp3 output.mp4

trim video/audio having start time and end time

ffmpeg -t EE:EE:EE -i input.mp4 -ss SS:SS:SS output.mp4

E: end time S: start time

concat multiple videos or audios

create file inputs.txt near files that you want to merge, add following lines:

file '<file1-name>'
file '<file2-name>'

then use ffmpeg like so:

ffmpeg -f concat -i inputs.txt -c copy output.flv

Add -safe 0 before -i if Unsafe file name occurred!

convert mp4 to mp3

ffmpeg -i filename.mp4 filename.mp3

Export first frame as image from video

ffmpeg -i input.flv -r 1 -f image2 export.jpeg

download online streams

link1

link2

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