【发布时间】:2017-01-28 05:39:10
【问题描述】:
我正在尝试在半透明的 h264 视频上添加 png 水印(带 alpha 通道)。通过使用叠加过滤器,我设法为视频添加了水印。
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "[0][1] overlay=0:0" -c:v libx264 -an output.mp4
但覆盖过滤器不提供透明选项。所以我尝试使用混合过滤器。但是,当我使用原点解析时,会出现错误消息。
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "[0][1]blend=all_mode=overlay:all_opacity=0.3" -c:v libx264 -an output.mp4
输出:
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.41.100
Duration: 00:00:45.08, start: 0.000000, bitrate: 1872 kb/s
Stream #0:0(und): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 1869 kb/s, 29.72 fps, 30 tbr, 16k tbn, 32k tbc (default)
Metadata:
handler_name : VideoHandler
Input #1, png_pipe, from 'watermark.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba(pc), 64x64, 25 tbr, 25 tbn, 25 tbc
[Parsed_blend_0 @ 00750600] First input link top parameters (size 1920x1080, SAR 0:1) do not match the corresponding second input link bottom parameters (64x64, SAR 0:1)
[Parsed_blend_0 @ 00750600] Failed to configure output pad on Parsed_blend_0
Error configuring complex filters.
Invalid argument
结果看起来像是参数的一些分辨率问题。所以我尝试在混合之前缩放水印。
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "[0:0]scale=1920x1080[a]; [1:0]scale=1920x1080[b]; [a][b]blend=all_mode=overlay:all_opacity=0.3" -c:v libx264 -an output.mp4
FFMPEG 使用这些参数。但是输出不是我所期望的,因为水印已经被拉伸了。 有什么想法可以混合不同分辨率的水印而不拉伸到具有透明度的视频?
这里是测试文件。 (ffmpeg 版本 3.1.2) https://drive.google.com/open?id=0B2X3VLS01TogdHVJZ2I1ZC1GUUU https://drive.google.com/open?id=0B2X3VLS01TogbjhuZTlBOFFpN1k
【问题讨论】:
-
对于其他人,为了降低叠加水印的不透明度,我只是编辑了 .png,将其降低到 50% 的不透明度,将其重新保存为 .png 并使用它。效果很好
标签: filter ffmpeg transparency blend