FFmpeg与音视频流媒体工程开发相关

[FFmpeg]当对Png图进行滤镜scale后,透明背景变黑的

2020-10-13  本文已影响0人  _小老虎_

发生情况

ffmpeg -v error -i 16183_1_1.mp4 \
-framerate 10 -t 3.000000 -loop 1 -i a.png \
-filter_complex "[1:v]scale=1280:714[node1_f0_media1];[node1_f0_media1]setpts=PTS+0.000000/TB[node1_f1_media1];[node1_f1_media1]scale=215:120[node1_f2_media1];[0:v][node1_f2_media1]overlay=x='if(between(t,0.000000,3.000000),0,NAN)':0[node1_f3_media1]"  \
-map '[node1_f3_media1]' \
-vcodec libx264 -an  -y out.mp4

发现scale之后png背景变成黑色(不scale不会有这种问题)

解决方法

ffmpeg -v error -i 16183_1_1.mp4\
 -framerate 10 -t 3.000000 -loop 1 -i a.png \
-filter_complex "[1:v]premultiply=inplace=1,scale=1280:714[node1_f0_media1];[node1_f0_media1]setpts=PTS+0.000000/TB[node1_f1_media1];[node1_f1_media1]premultiply=inplace=1,scale=215:120[node1_f2_media1];[0:v][node1_f2_media1]overlay=x='if(between(t,0.000000,3.000000),0,NAN)':0[node1_f3_media1]"  \
-map '[node1_f3_media1]' \
-vcodec libx264 -an  -y out.mp4

参考:http://www.ffmpeg.org/ffmpeg-filters.html#premultiply

image.png

博客:https://xbuba.com/questions/48144440

上一篇下一篇

猜你喜欢

热点阅读