Skip to content

Instantly share code, notes, and snippets.

@twmbx
Created Apr 19, 2020
Embed
What would you like to do?
FFMPEG complex Video Trim
# cut out parts of a video by splitting it into parts delineated by seconds
# then combining them to create a single video
# example splits into 4 and then combines.
ffmpeg -i input-video.ext -filter_complex "
[0:v]split=4[vc1][vc2][vc3][vc4],
[vc1]trim=00:911,setpts=PTS-STARTPTS[v1],
[vc2]trim=974:2971,setpts=PTS-STARTPTS[v2],
[vc3]trim=2997:5129,setpts=PTS-STARTPTS[v3],
[vc4]trim=5155:5915,setpts=PTS-STARTPTS[v4],
[0:a]asplit=4[ac1][ac2][ac3][ac4],
[ac1]atrim=00:911,asetpts=PTS-STARTPTS[a1],
[ac2]atrim=974:2971,asetpts=PTS-STARTPTS[a2],
[ac3]atrim=2997:5129,asetpts=PTS-STARTPTS[a3],
[ac4]atrim=5155:5915,asetpts=PTS-STARTPTS[a4],
[v1][a1][v2][a2][v3][a3][v4][a4] concat=n=4:v=1:a=1[v][a]" -map "[v]" -map "[a]" output-video.ext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment