我使用ffmpeg
命令将一个视频覆盖在另一个视频上。
最短的in2.mp4
是30秒,我想重复它,直到最长的in1.avi
停止。使用以下命令,最短的一次覆盖,最长的一次持续到结束。
ffmpeg -i in1.avi -i in2.mp4 -filter_complex "[0:v]setpts=PTS-STARTPTS, scale=1920x1080[top];[1:v]setpts=PTS-STARTPTS, scale=1920x1080, format=yuva420p, colorchannelmixer=aa=0.5[bottom]; [top][bottom]overlay=shortest=0" -acodec libvo_aacenc -vcodec libx264 out.mp4
我尝试在loop=-1
之后将-filter_complex
放在不同的地方,但收到错误
No such filter: 'loop' Error initializing complex filters. Invalid argument
完成输出:
ffmpeg -i in1.avi -i in2.mp4 -filter_complex "[0:v]setpts=PTS-STARTPTS, scale=1920x1080[top];[1:v]setpts=PTS-STARTPTS, scale=1920x1080, format=yuva420p, colorchannelmixer=aa=0.5,loop=-1[bottom]; [top][bottom]overlay=shortest=0" -acodec libvo_aacenc -vcodec libx264 out.mp4
ffmpeg version 2.8.4 Copyright (c) 2000-2015 the FFmpeg developers built with gcc 5.2.0 (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-libdcadec --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. 31.100 / 54. 31.100 libavcodec 56. 60.100 /
56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 /
1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Input #0, avi, from 'in1.avi': Metadata:
encoder : Lavf57.32.100 Duration: 00:03:03.28, start: 0.000000, bitrate: 3003 kb/s
Stream #0:0: Video: h264 (High 4:4:4 Predictive) (H264 / 0x34363248), yuv444p, 1920x1080 [SAR 1:1 DAR 16:9], 160 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Stream #0:1: Audio: pcm_f32le ([3][0][0][0] / 0x0003), 44100 Hz, stereo, flt, 2822 kb/s Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'in2.mp4': Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41isomavc1
creation_time : 2016-11-05 17:25:45 Duration: 00:00:15.02, start: 0.000000, bitrate: 4071 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 3815 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
Metadata:
creation_time : 2016-11-05 17:25:45
handler_name : L-SMASH Video Handler
encoder : AVC Coding
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
Metadata:
creation_time : 2016-11-05 17:25:45
handler_name : L-SMASH Audio Handler [AVFilterGraph @ 056a41e0] No such filter: 'loop' Error initializing complex filters. Invalid argument
答案 0 :(得分:3)
ffmpeg
对于循环过滤器来说太旧了。overlay=shortest=1
或永远循环。示例:
ffmpeg -i in1.avi -i in2.mp4 -filter_complex
"[0:v]setpts=PTS-STARTPTS, scale=1920x1080[top];
[1:v]loop=-1:size=750, setpts=N/FRAME_RATE/TB, scale=1920x1080, format=yuva420p, colorchannelmixer=aa=0.5[bottom];
[top][bottom]overlay=shortest=1, format=yuv420p"
out.mp4