Monday, 17 June 2019

Some ffmpeg usage examples

Here are a few ffmpeg examples I have used on occasion:

Basic mkv to mp4 conversion
 ffmpeg -i original.mkv -vcodec copy -acodec copy new.mp4


Advanced mkv to mp4 conversion (copy multiple streams) 
 ffmpeg -i original.mkv -map 0:a -map 0:v -map 0:s -c:v copy -c:a copy -c:a copy -c:s mov_text new.mp4


Transcode to huffyuv + flac
 ffmpeg -i original.avi -f avi -c:v huffyuv -c:a flac new.avi


Copy video section (with audio)
 ffmpeg -i original.avi -c:v copy -c:a copy -ss 00:00:03.000 -t 00:00:26.000 new.part.avi


Reverse video
 ffmpeg -i original.avi -vf reverse -c:v huffyuv new.avi


Insert subtitles
 ffmpeg -i original.mp4 -i subtitles.srt -c:v copy -c:a copy -c:s mov_text new.mp4


Concat multiple files
 # cat part.list.txt
   file old.01.mp4
   file old.02.mp4
   file old.03.mp4

 ffmpeg -safe 0 -f concat -i part.list.txt -c:v copy -c:a copy new.mp4


Convert DVD without transcoding
 ffmpeg -i concat:VTS_07_1.VOB\|VTS_07_2.VOB\|VTS_07_3.VOB -map 0:v -map 0:a -c:v copy -c:a copy new.avi


Slow down video
 ffmpeg -i input.avi -filter:v "setpts=2.0*PTS" -c:v huffyuv output.avi


Speed up video
 ffmpeg -i input.avi -filter:v "setpts=0.5*PTS" -c:v huffyuv output.avi

No comments: