personal cheat bookmark of ffmpeg
commands I've used. I may only add new cheat whenever I duck-searched ffmpeg
commands to use, which I don't use ffmpeg
everyday.
ffmpeg -ss 2 -t 9 -i input.mkv -vf "fps=10,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
Retrieved from: https://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality
ffmpeg -ss 00:01:00 -to 00:02:00 -i input.mp4 -c copy output.mp4
Retrieved from: https://stackoverflow.com/questions/18444194/cutting-the-videos-based-on-start-and-end-time-using-ffmpeg
Time format is hh:mm:ss.ms
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4
Modify the -crf
param. Or
ffmpeg -i input.mp4 -b 800k output.mp4
Modify the -b
param
Retrieved from: https://unix.stackexchange.com/questions/28803/how-can-i-reduce-a-videos-size-with-ffmpeg
With re-encoding:
ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac output.mp4
Without re-encoding:
ffmpeg -i video.mp4 -i audio.wav -c copy output.mkv
Retrieved from: https://superuser.com/questions/277642/how-to-merge-audio-and-video-file-in-ffmpeg
ffmpeg -i input-video.avi -vn -acodec copy output-audio.aac
-vn
means no videoacodec copy
means to copy audio encoding from what's already on the video, but sometimes it doesn't work for me so I just leave this option.
Retrieved from: https://stackoverflow.com/questions/9913032/how-can-i-extract-audio-from-video-with-ffmpeg
ffmpeg -i input_file.mkv -c copy -an output_file.mkv
- use the
-an
flag
Retrieved from: https://superuser.com/questions/268985/remove-audio-from-video-file-with-ffmpeg
ffmpeg -i input.mp3 output.ogg
Probably also works with other format
This list is incomplete, you can expand by invading foreign country suggesting inputs.