我尝试使用ffmpeg将白色叠加框添加到从YouTube下载的mp4文件中。我知道语法,它可以用小视频工作,但是我很难让它在更长的时间内工作。这是确切的命令:
ffmpeg -i intro.mp4 -strict -2 -vf "color=white:200x50 [over]; [in][over] overlay=250:320:enable=between(t\,0\,52) [out]" out.mp4
最初,它就像一个魅力:
$ ffmpeg -i intro.mp4 -preset slow -strict -2 -vf "color=white:200x50 [over]; [in][over] overlay=250:320:enable=between(t\,0\,52) [out]" -t 60 out.mp4
ffmpeg version 2.5.3 Copyright (c) 2000-2015 the FFmpeg developers
built on Mar 26 2015 23:00:53 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.102 / 56. 15.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'intro.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2014-01-30 16:48:50
Duration: 00:13:30.70, start: 0.000000, bitrate: 692 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 497 kb/s, 25 fps, 25 tbr, 50 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 192 kb/s (default)
Metadata:
creation_time : 2014-01-30 16:48:54
handler_name : IsoMedia File Produced by Google, 5-11-2011
File 'out.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0x7fa8cb82fa00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
[libx264 @ 0x7fa8cb82fa00] profile High, level 3.1
[libx264 @ 0x7fa8cb82fa00] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 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=3 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=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 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:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf56.15.102
Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720, q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc56.13.100 libx264
Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2014-01-30 16:48:54
handler_name : IsoMedia File Produced by Google, 5-11-2011
encoder : Lavc56.13.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame= 1500 fps= 47 q=-1.0 Lsize= 2518kB time=00:01:00.00 bitrate= 343.8kbits/s
但过了一段时间后,该命令开始大喊大叫:
frame=20269 fps= 21 q=-1.0 Lsize= 23283kB time=00:13:30.70 bitrate= 235.3kbits/s dup=0 drop=548431
它永远不会结束。任何线索?
答案 0 :(得分:3)
使用
ffmpeg -i intro.mp4 -strict -2 -vf "color=white:200x50 [over]; [in][over] overlay=250:320:enable=between(t\,0\,52):shortest=1 [out]" out.mp4
主要输入是有限长度的,但次要输入不是,所以它继续进行。这不应该发生。它应该在主要输入时终止,但我测试了你的命令并且可以重现你得到的行为。添加shortest=1
可以避免它。