基础切割 : 速度快/可能丢帧
ffmpeg -i input.mp4 -ss 00:00:05 -t 00:00:10 -y output.mp4
ffmpeg -i input.mp4 -ss 00:00:05 -t 00:00:10 -c copy -y output.mp4
ffmpeg -i input.mp4 -ss 00:00:05 -t 00:00:10 -c:v copy -c:a copy -y output.mp4
ffmpeg -i input.mp4 -ss 00:00:05 -to 00:00:10 -y output.mp4
ffmpeg -i input.mp4 -ss 00:00:05 -to 00:00:10 -threads 0 -y output.mp4
重新编码:速度非常慢/不丢帧
速度非常慢,输出速度和实际时间的比例为0.01-0.2左右
当基本截取出现开头和结尾丢帧的情况时,使用以下重新编码的方式截取
举例:
截取一个4k 10s长的视频
需要100s左右 谨慎使用
ffmpeg -i input.mp4 -ss 00:00:05 -t 00:00:10 -c:v libx264 -c:a aac -strict experimental -b:a 98k -y output.mp4
-ss: 开始时间
00:00:05.500
时:分:秒.毫秒
-t: 时长duration
-to: 结束时间
-c copy: 复制音轨和视频轨道
-c:v copy: 复制视频轨道
-c:v libx264: 对视频轨道重新编码,libx264:一个常用的视频编码格式
-c:v libx265: libx265 是一种新的编码格式:hevc
-c:a copy: 复制音轨
-c:a aac: 对音频轨道重新编码
-b:v 98k: 对视频重新编码,指定码率
-y: 覆盖output.mp4
-threads: 多线程
-threads 0
最佳
-threads 1
单线程
-threads 2
2个线程,例如Intel Core 2 Duo
无
默认,也是最佳