我正在尝试使用 ffmpeg 完成一个简单的任务。我已经预先生成了大约 100 张 png 图像(所有相同的分辨率)并单独生成了一个列表,供 ffmpeg 使用将它们连接到视频中。每个帧可能被使用不止一次。输出视频大约为 10,000 帧。
问题是 ffmpeg 停在大约 4000 帧时没有错误。最终的视频没有错误。
ffmpeg 命令:
ffmpeg -f concat -i frame_list.txt -vf fps=10 output.mov
frame_list.txt 示例:
file 'frame_0045.png'
file 'frame_0046.png'
file 'frame_0047.png'
file 'frame_0046.png'
file 'frame_0047.png'
ffmpeg 输出:
ffmpeg version 2.3.3- http://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2014 the FFmpeg developers
built on Sep 2 2014 16:32:53 with gcc 4.8 (Debian 4.8.3-9)
configuration: --enable-gpl --enable-version3 --disable-shared
--disable-debug --enable-runtime-cpudetect --enable-libmp3lame
--enable-libx264 --enable-libwebp --enable-libspeex
--enable-libvorbis --enable-libvpx --enable-libfreetype
--enable-fontconfig --enable-libxvid --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc
--enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg
--enable-libopus --disable-ffserver --enable-libass --enable-gnutls
--cc=gcc-4.8
libavutil 52. 92.100 / 52. 92.100
libavcodec 55. 69.100 / 55. 69.100
libavformat 55. 48.100 / 55. 48.100
libavdevice 55. 13.102 / 55. 13.102
libavfilter 4. 11.100 / 4. 11.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, concat, from 'frame_list.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgba64be, 1920x400 [SAR 72:72 DAR 24:5], 25 tbr, 25 tbn, 25 tbc
File 'output.mov' already exists. Overwrite ? [y/N] No pixel format
specified, yuv444p for H.264 encoding chosen.
Use -pix_fmt yuv420p for compatibility with outdated media players.
[libx264 @ 0x38a6e20] using SAR=1/1
[libx264 @ 0x38a6e20] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x38a6e20] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 0x38a6e20] 264 - core 142 r50 dd79a61 - H.264/MPEG-4 AVC
codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html -
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7
psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4
threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1
interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2
b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250
keyint_min=10 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00
Output #0, mov, to 'output.mov':
Metadata:
encoder : Lavf55.48.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv444p,
1920x400 [SAR 1:1 DAR 24:5], q=-1--1, 10 fps, 10240 tbn, 10 tbc
Metadata:
encoder : Lavc55.69.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Blah blah 执行了所有连接,然后由于未知原因停止在 frame 4040
frame= 4040 fps= 13 q=-1.0 Lsize= 2301kB time=00:06:43.80 bitrate= 46.7kbits/s
video:2254kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.067943%
[libx264 @ 0x38a6e20] frame I:17 Avg QP:13.43 size: 22332
[libx264 @ 0x38a6e20] frame P:1297 Avg QP:12.44 size: 1003
[libx264 @ 0x38a6e20] frame B:2726 Avg QP:13.00 size: 230
[libx264 @ 0x38a6e20] consecutive B-frames: 9.9% 0.4% 0.2% 89.5%
[libx264 @ 0x38a6e20] mb I I16..4: 15.8% 68.5% 15.7%
[libx264 @ 0x38a6e20] mb P I16..4: 0.1% 0.5% 0.3% P16..4: 0.8% 0.2% 0.2% 0.0% 0.0% skip:98.0%
[libx264 @ 0x38a6e20] mb B I16..4: 0.0% 0.1% 0.0% B16..8: 1.6% 0.1% 0.0% direct: 0.0% skip:98.2% L0:51.6% L1:45.9% BI: 2.6%
[libx264 @ 0x38a6e20] 8x8 transform intra:62.7% inter:16.1%
[libx264 @ 0x38a6e20] coded y,u,v intra: 14.7% 8.5% 9.2% inter: 0.1% 0.0% 0.0%
[libx264 @ 0x38a6e20] i16 v,h,dc,p: 60% 35% 4% 0%
[libx264 @ 0x38a6e20] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 41% 2% 56% 0% 0% 0% 0% 0% 0%
[libx264 @ 0x38a6e20] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 36% 14% 21% 6% 4% 5% 5% 6% 4%
[libx264 @ 0x38a6e20] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x38a6e20] ref P L0: 59.3% 5.1% 20.4% 15.2%
[libx264 @ 0x38a6e20] ref B L0: 72.2% 22.5% 5.3%
[libx264 @ 0x38a6e20] ref B L1: 97.2% 2.8%
[libx264 @ 0x38a6e20] kb/s:45.70
最佳答案
我确实在输出中看到了这个:
frame= 4040 fps= 13
再仔细看看这个:
Input #0, concat, from 'frame_list.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgba64be, 1920x400 [SAR 72:72 DAR 24:5], 25 tbr, 25 tbn, 25 tbc
它说的是 25 帧速率而不是输入的 10。所以 FFMPEG 认为它有 25FPS 的输入并且超过双倍 10,这就是为什么你在 4040 处停止并且没有使用所有 PNG。 10,000 帧除以 25FPS 输入等于 400 乘以 10FPS 输出等于 4000,然后停止。
试试这些参数:
ffmpeg -r 1/5 -f concat -i frame_list.txt -vf fps=10 output.mov
您可以看到您记录的是我上面提到的输入文件的默认帧率,即 25 FPS,没有指定输入的持续时间或比特率。
-r 1/5 表示每个图像的持续时间为 5 秒(每秒 1/5 帧的倒数)或者您可以更改它,但我认为它不会像您一样使用每个 PNG 两次说明。但是您可以使用该设置 1/10 来获得 10,000 帧输出,或者在获得每个 PNG 所需的显示时间后将多个输出视频文件组合在一起。只需确保每次在导出时为每个新 MOV 更改输出名称即可。
关于linux - Ffmpeg concat images 并没有完成所有图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32522578/