Skip to content

ffmpeg

Combining audio and video

1731926733.png

ffmpeg -i cat.mp4 -i cat2.mp4 -c:v copy -c:a aac result.mp4

Cropping video with ffmpeg

What didn't work:

ffmpeg -ss 00:08:05 -t 00:09:34 -i file.mp4 -pix_fmt yuv420p toji.mp4

What worked:

ffmpeg -ss 00:08:05 -to 00:09:34 -i file.mp4 -pix_fmt yuv420p toji.mp4

It should be ss which stands for start time and to which stands for end time.

What took the least amount of time:

ffmpeg -ss 00:08:05 -to 00:09:34 -i file.mp4 -pix_fmt yuv420p -c copy toji.mp4

Making it more precise

For some reason, this command gave me a result that was longer than 2 seconds:

ffmpeg -ss 00:00:10 -t 00:00:12 -i sreema.mp4 -pix_fmt yuv420p -preset medium women-working.mp4

The solution was to use vframes to get the result to be more precise.

ffmpeg -y -ss 00:00:10 -i sreema.mp4 -vframes 110 -pix_fmt yuv420p -force_key_frames 0 women-working.mp4

Forcing thumbnail

ffmpeg -y -ss 00:00:26.900 -i sreema.mp4 -vframes 50 -pix_fmt yuv420p -force_key_frames 0 disc-turning.mp4

Burning subtitles to video

ffmpeg -ss 00:30:53 -to 00:31:11 -copyts -i "/home/vector/media/Season 6/The Sopranos S06E19 The Second Coming.mkv" -ss 00:30:53 -to 00:31:11 -vf subtitles="/home/vector/media/Season 6/The Sopranos S06E19 The Second Coming.srt" -pix_fmt yuv420p out.mp4

One image + audio

source: https://trac.ffmpeg.org/wiki/Slideshow#Addingaudio

ffmpeg -loop 1 -i brutedeforce.jpg -i 'Absurdity of goals [1DXxyjoppWnKM].m4a' -c:v libx264 -c:a copy -shortest -pix_fmt yuv420p out2.mp4

Comments