问题
This is my idea.
I want to cut the first 10s of video and the last 10s of video
Thank for help
回答1:
With re-encoding:
ffmpeg -ss 10 -i video.mp4 -filter_complex "[0]trim=10,setpts=PTS-STARTPTS[b];[b][0]overlay=shortest=1" -shortest -c:a copy out.mp4
-ss 10
sets the the amount to cut from beginning. trim=10
sets amount to cut from end. Caveat here is that due to a current bug with shortest=1
, this may not work on ffmpeg builds from 2017.
A bit of a hack method, which skips transcoding:
ffmpeg -ss 10 -i video.mp4 -ss 20 -i video.mp4 -c copy -map 1:0 -map 0 -shortest -f nut - | ffmpeg -f nut -i - -map 0 -map -0:0 -c copy out.mp4
Depending on the location keyframes, the trims at start and end won't be perfect. First ss
is starting trim. Second ss
is starting + ending
trim
来源:https://stackoverflow.com/questions/43515420/cut-video-with-ffmpeg