我用图像创建了一个视频幻灯片。
文档中说:
在此示例中,每个图像的持续时间为 5 秒(每秒 1/5 帧的倒数)。
ffmpeg -framerate 1/5 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
但是当我运行命令时,图片显示 2 秒,然后 3 秒什么都没有,然后显示下一张图片。
查看演示http://humor15.com/media/out2.mp4
我的命令:
' -loop 1' &
' -framerate 1' &
' -i "C:/test/bg.jpg"' &
' -framerate 1/5' &
' -i "C:/test/%03d.jpg"' &
' -loop 1' &
' -framerate 1' &
' -i "C:/test/logo.png"' &
' -i "C:/test/music.mp3"' &
' -filter_complex' &
' "[1:v]drawbox=t=5:c=white[fg];' &
' [0:v][fg]overlay=(W-w)/2:(H-h)/2:shortest=1,' &
' drawtext="fontsize=50:fontfile=/Windows/Fonts/arial.ttf:fontcolor=White:text="Created by Eterni-T":x=(w-text_w)/2:y=40:shadowx=1:shadowy=1",' &
' drawtext="fontsize=50:fontfile=/Windows/Fonts/arial.ttf:fontcolor=White:text="Laurence Collard (Simard) 1925-1999":x=w-text_w-10:y=h-text_h-10",' &
' drawbox=x=0:y=in_h-100:w=iw:h=100:[email protected]:t=50,' &
' drawbox=x=0:y=10:w=iw:h=100:[email protected]:t=50[bg];' &
' [bg][2:v]overlay=10:H-h-10:shortest=1,' &
' format=yuv420p[v]"' &
' -map "[v]"' &
' -c:v libx264' &
' -c:a aac -strict experimental' &
' -b:a 192k' &
' -r 30' &
' -movflags +faststart' &
' -shortest' &
' -map 3:a' &
' "C:/test/out2.mp4"';
输出:
ffmpeg version N-69587-g15a8846 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 --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --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 'C:/test/bg.jpg':
Duration: 00:00:01.00, start: 0.000000, bitrate: 1900 kb/s
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1920x1360 [SAR 1:1 DAR 24:17], 1 fps, 1 tbr, 1 tbn, 1 tbc
Input #1, image2, from 'C:/test/%03d.jpg':
Duration: 00:00:15.00, start: 0.000000, bitrate: N/A
Stream #1:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), 540x800, 0.20 fps, 0.20 tbr, 0.20 tbn, 0.20 tbc
Input #2, png_pipe, from 'C:/test/logo.png':
Duration: N/A, bitrate: N/A
Stream #2:0: Video: png, rgba, 453x209, 1 fps, 1 tbr, 1 tbn, 1 tbc
[mp3 @ 0000000004d14f60] Estimating duration from bitrate, this may be inaccurate
Input #3, mp3, from 'C:/test/music.mp3':
Duration: 00:02:18.40, start: 0.000000, bitrate: 224 kb/s
Stream #3:0: Audio: mp3, 44100 Hz, stereo, s16p, 224 kb/s
[swscaler @ 0000000004be6fe0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 0000000004c045e0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0000000004d096c0] using SAR=1/1
[libx264 @ 0000000004d096c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0000000004d096c0] profile High, level 5.0
[libx264 @ 0000000004d096c0] 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=12 lookahead_threads=2 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 'C:/test/out2.mp4':
Metadata:
encoder : Lavf56.19.100
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1360 [SAR 1:1 DAR 24:17], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
Metadata:
encoder : Lavc56.21.102 libx264
Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 192 kb/s
Metadata:
encoder : Lavc56.21.102 aac
Stream mapping:
Stream #0:0 (mjpeg) -> overlay:main (graph 0)
Stream #1:0 (mjpeg) -> drawbox (graph 0)
Stream #2:0 (png) -> overlay:overlay (graph 0)
format (graph 0) -> Stream #0:0 (libx264)
Stream #3:0 -> #0:1 (mp3 (native) -> aac (native))
Press [q] to stop, [?] for help
Input stream #1:0 frame changed from size:540x800 fmt:yuvj444p to size:1115x672 fmt:yuvj444p
[swscaler @ 0000000004cf6cc0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 000000001f622ca0] deprecated pixel format used, make sure you did set range correctly
frame= 90 fps= 88 q=29.0 size= 0kB time=00:00:01.06 bitrate= 0.4kbits/s dup=88 drop=0
frame= 120 fps= 77 q=29.0 size= 329kB time=00:00:02.06 bitrate=1304.5kbits/s dup=117 drop=0
frame= 150 fps= 72 q=29.0 size= 410kB time=00:00:03.06 bitrate=1094.2kbits/s dup=146 drop=0
frame= 180 fps= 68 q=29.0 size= 436kB time=00:00:04.06 bitrate= 879.1kbits/s dup=175 drop=0
Input stream #1:0 frame changed from size:1115x672 fmt:yuvj444p to size:1000x607 fmt:yuvj444p
[swscaler @ 000000001f77d1e0] deprecated pixel format used, make sure you did set range correctly
[swscaler @ 00000000051cc160] deprecated pixel format used, make sure you did set range correctly
frame= 240 fps= 62 q=29.0 size= 462kB time=00:00:06.06 bitrate= 623.6kbits/s dup=234 drop=0
frame= 270 fps= 60 q=29.0 size= 685kB time=00:00:07.06 bitrate= 793.9kbits/s dup=263 drop=0
frame= 300 fps= 60 q=29.0 size= 810kB time=00:00:08.06 bitrate= 822.2kbits/s dup=292 drop=0
frame= 330 fps= 60 q=29.0 size= 815kB time=00:00:09.06 bitrate= 736.0kbits/s dup=321 drop=0
[mp4 @ 0000000004d08c00] Starting second pass: moving the moov atom to the beginning of the file
frame= 330 fps= 52 q=-1.0 Lsize= 1288kB time=00:00:11.00 bitrate= 958.6kbits/s dup=321 drop=0
video:1013kB audio:262kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.014088%
[libx264 @ 0000000004d096c0] frame I:2 Avg QP:14.64 size:300458
[libx264 @ 0000000004d096c0] frame P:86 Avg QP:15.33 size: 4819
[libx264 @ 0000000004d096c0] frame B:242 Avg QP:23.55 size: 89
[libx264 @ 0000000004d096c0] consecutive B-frames: 2.1% 0.0% 0.9% 97.0%
[libx264 @ 0000000004d096c0] mb I I16..4: 1.7% 92.0% 6.3%
[libx264 @ 0000000004d096c0] mb P I16..4: 0.0% 0.9% 0.2% P16..4: 0.2% 0.0% 0.0% 0.0% 0.0% skip:98.6%
[libx264 @ 0000000004d096c0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.1% 0.0% 0.0% direct: 0.0% skip:99.9% L0:28.3% L1:71.7% BI: 0.0%
[libx264 @ 0000000004d096c0] 8x8 transform intra:87.8% inter:77.1%
[libx264 @ 0000000004d096c0] coded y,uvDC,uvAC intra: 93.7% 19.4% 11.7% inter: 0.0% 0.0% 0.0%
[libx264 @ 0000000004d096c0] i16 v,h,dc,p: 60% 29% 8% 2%
[libx264 @ 0000000004d096c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 19% 39% 3% 4% 3% 6% 4% 8%
[libx264 @ 0000000004d096c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 22% 9% 6% 9% 9% 10% 7% 9%
[libx264 @ 0000000004d096c0] i8c dc,h,v,p: 77% 14% 8% 1%
[libx264 @ 0000000004d096c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000000004d096c0] ref P L0: 84.9% 3.2% 6.7% 5.2%
[libx264 @ 0000000004d096c0] ref B L0: 72.9% 24.2% 2.9%
[libx264 @ 0000000004d096c0] ref B L1: 95.4% 4.6%
[libx264 @ 0000000004d096c0] kb/s:754.10