我正试图在之后将约20分钟的视频分成几个1分钟的块,但结果却非常奇怪。
我首先尝试在-ss
之后用-i
编写一个循环。
for m in $(seq 0 20); ffmpeg -i video.mov -ss $((60 * $m)) -t 60 -vcodec copy video.$m.1min.mov
我得到了一堆不同的“开始”时间和视频时长:
$ for f in *.1min.mov; do echo $f $(ffprobe $f 2>&1 | grep Duration); done
video.0.1min.mov Duration: 00:01:00.01, start: 0.000000, bitrate: 3014 kb/s
video.1.1min.mov Duration: 00:01:00.00, start: 0.012000, bitrate: 3002 kb/s
video.2.1min.mov Duration: 00:01:00.00, start: 0.012000, bitrate: 3002 kb/s
video.3.1min.mov Duration: 00:01:00.00, start: 0.011000, bitrate: 3002 kb/s
video.4.1min.mov Duration: 00:01:00.00, start: 0.010000, bitrate: 3001 kb/s
video.5.1min.mov Duration: 00:01:00.00, start: 0.010000, bitrate: 3002 kb/s
video.6.1min.mov Duration: 00:01:00.00, start: 0.009000, bitrate: 3003 kb/s
video.7.1min.mov Duration: 00:01:00.00, start: 0.009000, bitrate: 3006 kb/s
video.8.1min.mov Duration: 00:01:00.00, start: 0.008000, bitrate: 2999 kb/s
video.9.1min.mov Duration: 00:01:00.00, start: 0.007000, bitrate: 3003 kb/s
video.10.1min.mov Duration: 00:01:00.00, start: 0.007000, bitrate: 3002 kb/s
video.11.1min.mov Duration: 00:01:00.00, start: 0.006000, bitrate: 3002 kb/s
video.12.1min.mov Duration: 00:01:00.00, start: 0.006000, bitrate: 3005 kb/s
video.13.1min.mov Duration: 00:00:50.57, start: 9.438000, bitrate: 3004 kb/s
video.14.1min.mov Duration: 00:00:50.57, start: 9.438000, bitrate: 3003 kb/s
video.15.1min.mov Duration: 00:00:50.57, start: 9.437000, bitrate: 3004 kb/s
video.16.1min.mov Duration: 00:00:50.57, start: 9.436000, bitrate: 2998 kb/s
video.17.1min.mov Duration: 00:00:50.57, start: 9.436000, bitrate: 3004 kb/s
video.18.1min.mov Duration: 00:00:50.57, start: 9.435000, bitrate: 3005 kb/s
video.19.1min.mov Duration: 00:00:50.57, start: 9.435000, bitrate: 3004 kb/s
video.20.1min.mov Duration: 00:00:50.57, start: 9.434000, bitrate: 3001 kb/s
如果我改为在-ss
之前移动-i
:
for m in $(seq 0 20); ffmpeg -ss $((60 * $m)) -i video.mov -vcodec copy -t 60 video.$m.1min.mov
然后我得到了不错的开始时间,但可变长度:
$ for f in *.1min.mov; do echo $f $(ffprobe $f 2>&1 | grep Duration); done
video.0.1min.mov Duration: 00:01:00.01, start: 0.000000, bitrate: 3014 kb/s
video.1.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3003 kb/s
video.2.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3002 kb/s
video.3.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3002 kb/s
video.4.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3001 kb/s
video.5.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3001 kb/s
video.6.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3002 kb/s
video.7.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3005 kb/s
video.8.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3002 kb/s
video.9.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3002 kb/s
video.10.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3007 kb/s
video.11.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3002 kb/s
video.12.1min.mov Duration: 00:01:10.00, start: 0.000000, bitrate: 3004 kb/s
video.13.1min.mov Duration: 00:01:00.57, start: 0.000000, bitrate: 3003 kb/s
video.14.1min.mov Duration: 00:01:00.57, start: 0.000000, bitrate: 3003 kb/s
video.15.1min.mov Duration: 00:01:00.57, start: 0.000000, bitrate: 3005 kb/s
video.16.1min.mov Duration: 00:01:00.57, start: 0.000000, bitrate: 3001 kb/s
video.17.1min.mov Duration: 00:01:00.57, start: 0.000000, bitrate: 3004 kb/s
video.18.1min.mov Duration: 00:01:00.57, start: 0.000000, bitrate: 3002 kb/s
video.19.1min.mov Duration: 00:01:00.57, start: 0.000000, bitrate: 3006 kb/s
video.20.1min.mov Duration: 00:01:00.57, start: 0.000000, bitrate: 3001 kb/s
这里发生了什么?如何获得具有均匀持续时间和合理开始时间的视频?我的输入视频有点奇怪吗? (我无法分享,抱歉!)
答案 0 :(得分:0)
我认为问题在于ffmpeg试图变得聪明并且不重新编码视频。这使得它运行得很快,但代价是我在问题中描述的奇怪的开始和持续时间效应。
解决方案是重新编码视频:
for m in $(seq 0 20); ffmpeg -i video.mov -ss $((60 * $m)) -t 60 video.$m.1min.mov
运行速度慢了100倍,但它至少会产生具有我期望的开始和持续时间的视频:
$ for f in *.1min.mov; do echo $f $(ffprobe $f 2>&1 | grep Duration); done
video.0.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2108 kb/s
video.1.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2519 kb/s
video.2.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2318 kb/s
video.3.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2573 kb/s
video.4.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2104 kb/s
video.5.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2292 kb/s
video.6.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2219 kb/s
video.7.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2381 kb/s
video.8.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2184 kb/s
video.9.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2726 kb/s
video.10.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2253 kb/s
video.11.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 1872 kb/s
video.12.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2418 kb/s
video.13.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2624 kb/s
video.14.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2252 kb/s
video.15.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2426 kb/s
video.16.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2491 kb/s
video.17.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2276 kb/s
video.18.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2249 kb/s
video.19.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2071 kb/s
video.20.1min.mov Duration: 00:01:00.00, start: 0.000000, bitrate: 2317 kb/s