Ffmpeg concat图像无法完成所有图像

时间:2015-09-11 11:37:45

标签: linux video ffmpeg

我正在尝试用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

1 个答案:

答案 0 :(得分:2)

我确实在输出中看到了这一点:

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两次说明。但是,在获得每个PNG所需的显示时间后,您可以使用该设置1/10来获得10,000帧输出或将多个输出视频文件组合在一起。只需确保在导出时每次为每个新MOV更改输出名称。