Eu quero mesclar dois arquivos de vídeo com um efeito de cross-fade entre eles (apenas um segundo), mas sem desvanecer para preto ou branco ou qualquer cor - tem que ser uma transição suave de um vídeo para outro.
Eu encontrei esta resposta para ser a mais útil até agora - aqui é o meu exemplo (baseado nessa solução):
ffmpeg -i e:/ffmpeg/part1.mp4 -i e:/ffmpeg/part2.mp4 -f lavfi -i color=black:s=1920x1080 -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=10:d=1:alpha=1,setpts=PTS-STARTPTS[va0]; \
[1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+10/TB[va1]; \
[2:v]trim=duration=18[over]; \
[over][va0]overlay[over1]; \
[over1][va1]overlay=format=yuv420[outv]" \
-vcodec libx264 -map [outv] e:/ffmpeg/output.mp4
ffmpeg version N-66278-g91459bd Copyright (c) 2000-2014 the FFmpeg developers
built on Sep 14 2014 22:14:38 with gcc 4.8.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzli
b --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu
ray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-
libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --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 --enab
le-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
libavutil 54. 7.100 / 54. 7.100
libavcodec 56. 1.100 / 56. 1.100
libavformat 56. 4.101 / 56. 4.101
libavdevice 56. 0.100 / 56. 0.100
libavfilter 5. 1.100 / 5. 1.100
libswscale 3. 0.100 / 3. 0.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 0.100 / 53. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'e:/ffmpeg/part1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
Duration: 00:00:11.24, start: 0.000000, bitrate: 19916 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9],
19768 kb/s, 29.65 fps, 30 tbr, 30k tbn, 60k tbc (default)
Metadata:
handler_name : VideoHandler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 97 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'e:/ffmpeg/part2.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
Duration: 00:00:08.23, start: 0.000000, bitrate: 19795 kb/s
Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9],
19670 kb/s, 29.50 fps, 30 tbr, 30k tbn, 60k tbc (default)
Metadata:
handler_name : VideoHandler
encoder : AVC Coding
Stream #1:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 97 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #2, lavfi, from 'color=black:s=1920x1080':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #2:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 25 tbr,
25 tbn, 25 tbc
[libx264 @ 0000000004330980] using SAR=1/1
[libx264 @ 0000000004330980] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
[libx264 @ 0000000004330980] profile High, level 4.0
[libx264 @ 0000000004330980] 264 - core 142 r2479 dd79a61 - H.264/MPEG-4 AVC codec - Copyleft 2003-2
014 - 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 dead
zone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 deci
mate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 dir
ect=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahe
ad=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 'e:/ffmpeg/output.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
encoder : Lavf56.4.101
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1080 [SAR 1:1 DAR 16:
9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
Metadata:
encoder : Lavc56.1.100 libx264
Stream mapping:
Stream #0:0 (h264) -> format
Stream #1:0 (h264) -> format
Stream #2:0 (rawvideo) -> trim
overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
frame= 451 fps=4.5 q=-1.0 Lsize= 11032kB time=00:00:17.96 bitrate=5031.9kbits/s dup=0 drop=7
video:11028kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.036493%
[libx264 @ 0000000004330980] frame I:11 Avg QP:20.72 size: 63930
[libx264 @ 0000000004330980] frame P:368 Avg QP:23.84 size: 26880
[libx264 @ 0000000004330980] frame B:72 Avg QP:25.29 size: 9679
[libx264 @ 0000000004330980] consecutive B-frames: 69.0% 28.8% 1.3% 0.9%
[libx264 @ 0000000004330980] mb I I16..4: 16.7% 70.0% 13.3%
[libx264 @ 0000000004330980] mb P I16..4: 4.6% 10.7% 0.5% P16..4: 56.9% 7.8% 5.4% 0.0% 0.0%
skip:14.2%
[libx264 @ 0000000004330980] mb B I16..4: 0.2% 0.4% 0.0% B16..8: 42.9% 1.8% 0.2% direct: 3.3
% skip:51.3% L0:39.3% L1:59.7% BI: 0.9%
[libx264 @ 0000000004330980] 8x8 transform intra:68.1% inter:89.7%
[libx264 @ 0000000004330980] coded y,uvDC,uvAC intra: 43.7% 66.3% 4.2% inter: 21.4% 52.4% 0.0%
[libx264 @ 0000000004330980] i16 v,h,dc,p: 38% 17% 10% 35%
[libx264 @ 0000000004330980] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 16% 28% 4% 5% 5% 5% 5% 4%
[libx264 @ 0000000004330980] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 35% 23% 15% 4% 6% 5% 5% 4% 3%
[libx264 @ 0000000004330980] i8c dc,h,v,p: 51% 18% 25% 6%
[libx264 @ 0000000004330980] Weighted P-Frames: Y:3.5% UV:2.7%
[libx264 @ 0000000004330980] ref P L0: 76.4% 9.8% 10.4% 3.3% 0.1%
[libx264 @ 0000000004330980] ref B L0: 91.4% 8.5% 0.0%
[libx264 @ 0000000004330980] ref B L1: 99.6% 0.4%
[libx264 @ 0000000004330980] kb/s:5007.46
O problema é que não há som no vídeo de saída.
Estou procurando algo que participe de dois vídeos sem remover o áudio. Eu poderia juntar o áudio separadamente usando outro software (como por exemplo o Audacity) eventualmente, mas se há uma maneira de fazer tudo isso no FFmpeg, então eu gostaria de saber.
Me desculpe se essa é uma pergunta ruim, mas não estou muito familiarizada com filtros de vídeo ou codificação de vídeo. Acabei de descobrir que o FFmpeg funciona melhor para mim (geralmente eu o uso apenas para conversões de arquivos) e tentei juntar dois vídeos com o efeito de transição, mas nenhuma das soluções que encontrei funcionou.