-->
Collection of shortcuts for FFMPEG

Collection of shortcuts for FFMPEG

2022, Nov 23    

I use ffmpeg for short video editing tasks. This is my personal collection of shortcuts for ffmpeg that I use from day to day.

Trim Video:

# from 5:20 to 15:20 copy (may fail when output format is diffrent)
$ ffmpeg -ss 00:05:20 -i input.mp4 -t 00:10:00 -c:v copy -c:a copy output.mp4

# from 5:20 to 10:00 copy (may fail when output format is diffrent)
$ ffmpeg -ss 00:05:20 -i input.mp4 -to 00:10:00 -c:v copy -c:a copy output.mp4

# from 5:20 to 10:00 re-encoding
$ ffmpeg -ss 00:05:20 -accurate_seek -i input.mp4 -to 00:10:00 -c:v libx264 -c:a aac output.mp4

# last 10:00 of video copy
$ ffmpeg -sseof -00:10:00 -i input.mp4 -c copy output.mp4

Extraction:

# Extract Audio
ffmpeg -i input.mp4 -q:a 0 -map a sample.mp3

#Extract Video
ffmpeg -i input.mp4 -c copy -an input.mp4


Changing Speed:

# speed up video and audio at the same time
# 2x speed up command:
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2[a]" -map "[v]" -map "[a]" output.mp4
# 1.5x speed up command:
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.666*PTS[v];[0:a]atempo=1.5[a]" -map "[v]" -map "[a]" output.mp4
# speed up formula (x must be between 0 and 2):
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=<1/x>*PTS[v];[0:a]atempo=<x>[a]" -map "[v]" -map "[a]" output.mp4

-->
-->