使用ffmpeg剪切视频。 [英] Cut video with ffmpeg.
本文介绍了使用ffmpeg剪切视频。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的主意。
我想剪切视频的前十个和视频的后十个
I want to cut the first 10s of video and the last 10s of video
感谢帮助
推荐答案
使用重新编码:
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
设置要从头开始削减的金额。 trim = 10
设置要从末尾削减的金额。需要说明的是,由于当前存在 shortest = 1
的错误,这可能不适用于2017年以后的ffmpeg版本。
-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.
有点hack方法,跳过转码:
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
根据位置关键帧,开始和结束时的修剪将不完美。首先 ss
开始修剪。第二个 ss
是开始+结束
修剪
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
这篇关于使用ffmpeg剪切视频。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文