ffmpeg屏幕混合模式使透明png变为粉红色

时间:2013-11-18 10:23:50

标签: video ffmpeg screen mp4 blending

我有一系列具有透明度的PNG文件 - 我想在视频的顶部对它们进行屏幕混合

ffmpeg -i video.mp4 -i "Images/%03d.png" -filter_complex "blend=all_mode='screen':all_opacity=0.7" output.mp4

图像确实合并在视频的顶部,但带有粉红色的叠加层?

我还尝试添加“-vcodec png”和“-vcodec libx264”并尝试.mov视频,但结果相同。

ffmpeg version N-58061-g5231eec Copyright (c) 2000-2013 the FFmpeg developers
built on Nov 14 2013 05:35:15 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg- 
static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' 
--extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-
ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-
cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-
libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --
enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --
enable-libvpx
libavutil      52. 52.100 / 52. 52.100
libavcodec     55. 41.101 / 55. 41.101
libavformat    55. 21.100 / 55. 21.100
libavdevice    55.  5.100 / 55.  5.100
libavfilter     3. 91.100 /  3. 91.100
libswscale      2.  5.101 /  2.  5.101
libswresample   0. 17.104 /  0. 17.104
libpostproc    52.  3.100 / 52.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand     : isom
minor_version   : 512
compatible_brands: isomiso2avc1mp41
encoder         : Lavf54.2.100
Duration: 00:00:18.88, start: 0.000000, bitrate: 595 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, 461 kb/s,  
25.16 fps, 25 tbr, 1000k tbn, 2000k tbc (default)
Metadata:
handler_name    : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s 
(default)
Metadata:
handler_name    : SoundHandler
Input #1, image2, from 'Dots2/%03d.png':
Duration: 00:00:10.00, start: 0.000000, bitrate: N/A
Stream #1:0: Video: png, rgba, 640x480, 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x292ad60] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x292ad60] profile High, level 3.0
[libx264 @ 0x292ad60] 264 - core 129 r2230 1cffe9f - H.264/MPEG-4 AVC codec - Copyleft 
2003-2012 - 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 'output_Dots.mp4':
Metadata:
major_brand     : isom
Stream #0:1(und): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 
s16, 128 kb/s (default)
Metadata:
handler_name    : SoundHandler
Stream mapping:
Stream #0:0 (h264) -> blend:top (graph 0)
Stream #1:0 (png) -> blend:bottom (graph 0)
blend (graph 0) -> Stream #0:0 (libx264)
Stream #0:1 -> #0:1 (aac -> libvo_aacenc)
Press [q] to stop, [?] for help
frame=  475 fps=105 q=-1.0 Lsize=    1660kB time=00:00:18.92 bitrate= 718.7kbits/s    
video:1349kB audio:295kB subtitle:0 global headers:0kB muxing overhead 0.993598%
[libx264 @ 0x292ad60] frame I:2     Avg QP:19.79  size: 33501
[libx264 @ 0x292ad60] frame P:176   Avg QP:23.16  size:  5651
[libx264 @ 0x292ad60] frame B:297   Avg QP:27.76  size:  1074
[libx264 @ 0x292ad60] consecutive B-frames: 13.3%  8.8%  3.8% 74.1%
[libx264 @ 0x292ad60] mb I  I16..4:  1.7% 69.9% 28.4%
[libx264 @ 0x292ad60] mb P  I16..4:  3.3%  8.1%  1.0%  P16..4: 47.1% 14.7%  7.5%  0.0%  
0.0%    skip:18.3%
[libx264 @ 0x292ad60] mb B  I16..4:  0.1%  0.0%  0.0%  B16..8: 44.4%  2.6%  0.8%  
direct: 0.9%  skip:51.2%  L0:46.0% L1:50.5% BI: 3.5%
[libx264 @ 0x292ad60] 8x8 transform intra:64.9% inter:74.0%
[libx264 @ 0x292ad60] coded y,uvDC,uvAC intra: 47.0% 50.4% 13.1% inter: 11.8% 12.7% 0.5%
[libx264 @ 0x292ad60] i16 v,h,dc,p: 50% 18%  9% 23%
[libx264 @ 0x292ad60] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 15% 22%  4%  6%  6%  7%  5%  5%
[libx264 @ 0x292ad60] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 19% 19%  4%  6%  6%  6%  4%  4%
[libx264 @ 0x292ad60] i8c dc,h,v,p: 55% 17% 25%  2%
[libx264 @ 0x292ad60] Weighted P-Frames: Y:29.0% UV:23.9%
[libx264 @ 0x292ad60] ref P L0: 63.5% 20.9% 13.2%  2.3%  0.2%
[libx264 @ 0x292ad60] ref B L0: 96.8%  2.8%  0.4%
[libx264 @ 0x292ad60] ref B L1: 98.4%  1.6%
[libx264 @ 0x292ad60] kb/s:581.24

1 个答案:

答案 0 :(得分:10)

尝试在输出之前使用format = yuva422p10le(可能是类似的颜色空间,但这适用于我)转换颜色空间,也许您需要将叠加(或两个电影)的输入颜色空间转换为rgba(格式= rgba)。像这样:

ffmpeg -i ttt.jpg -vf "movie=fix2.png [fix]; [in] setsar=sar=1,format=rgba [inf]; [inf][fix] blend=all_mode=overlay:all_opacity=1,format=yuva422p10le [out]" -q:v 1 -y xxx.jpg

这种解决方法帮助我避免粉红色叠加。

ffmpeg version 2.0 Copyright (c) 2000-2013 the FFmpeg developers
  built on Sep 15 2013 12:22:11 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)