FFMPEG 转换图像后视频变成黑色

FFMPEG 转换图像后视频变成黑色

我正在尝试从编号为 1 到 100 的图像序列创建 mp4 视频。问题是我不断得到黑色的输出视频。每幅图像都是这样

在此处输入图片描述

一直到 100。我使用过的 FFMPEG 命令如下

ffmpeg -r 30 -i img%04d.png -c:v libx264 -crf 23 -pix_fmt yuv420p out.mp4 

该命令的输出如下,

ffmpeg version N-69608-g9dc45d1 Copyright (c) 2000-2015 the FFmpeg developers built with gcc  
4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-        
bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --
enable-libbluray --enab
le-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc 
--enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --   
enable-libopenjp
eg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex 
--enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-
amrwbenc --enable
-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 
--enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
libavutil      54. 18.100 / 54. 18.100
libavcodec     56. 21.102 / 56. 21.102
libavformat    56. 19.100 / 56. 19.100
libavdevice    56.  4.100 / 56.  4.100
libavfilter     5.  9.103 /  5.  9.103
libswscale      3.  1.101 /  3.  1.101
libswresample   1.  1.100 /  1.  1.100
libpostproc    53.  3.100 / 53.  3.100
Input #0, image2, from 'img%04d.png':
Duration: 00:00:04.00, start: 0.000000, bitrate: N/A
Stream #0:0: Video: png, rgba, 480x320, 25 fps, 25 tbr, 25 tbn, 25 tbc
File 'out.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 00000000049238a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 00000000049238a0] profile High, level 2.1
[libx264 @ 00000000049238a0] 264 - core 144 r2525 40bb568 - 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=-2 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=25 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, mp4, to 'out.mp4':
Metadata:
encoder         : Lavf56.19.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 480x320, q=-1--1, 30 fps,    
15360 tbn, 30 tbc
Metadata:
  encoder         : Lavc56.21.102 libx264
Stream mapping:
Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame=  100 fps=0.0 q=-1.0 Lsize=       5kB time=00:00:03.26 bitrate=  11.4kbits/s
video:3kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 77.850037%
[libx264 @ 00000000049238a0] frame I:1     Avg QP:10.00  size:    77
[libx264 @ 00000000049238a0] frame P:25    Avg QP:10.28  size:    25
[libx264 @ 00000000049238a0] frame B:74    Avg QP:13.68  size:    17
[libx264 @ 00000000049238a0] consecutive B-frames:  1.0%  0.0%  3.0% 96.0%
[libx264 @ 00000000049238a0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 00000000049238a0] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%     
0.0%    skip:100.0%
[libx264 @ 00000000049238a0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct:   
0.0%  skip:100.0%
[libx264 @ 00000000049238a0] 8x8 transform intra:0.0%
[libx264 @ 00000000049238a0] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 00000000049238a0] i16 v,h,dc,p: 95%  0%  5%  0%
[libx264 @ 00000000049238a0] i8c dc,h,v,p: 100%  0%  0%  0%
[libx264 @ 00000000049238a0] Weighted P-Frames: Y:0.0% UV:0.0%

所有 100 幅图像的编号均为“0001.png”至“0100.png”。我使用 Java 代码创建了这些图像。我使用 ffplay 播放了 3 秒长的输出视频,如下所示:

在此处输入图片描述

我查看了此处发布的其他相关问题,但所有建议均未解决问题。这是我第一次使用 FFMPEG,因此我不确定我遗漏了什么。如能提供帮助,我将不胜感激。

谢谢!

相关内容