I'm trying to add a png watermark (with alpha channel) over h264 video with semi transparent. By using overlay filter I managed to add watermark to the video.
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex "[0][1] overlay=0:0" -c:v libx264 -an output.mp4
But overlay filter does not provide transparent option. So I tried to use blend filter. However, when I use origin resolution, error message comes out.
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
Output:
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
The result looks like some resolution issue with the parameters. So that I tried to scale the watermark before blending.
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 works with these parameters. But the output wasn't I expected, because watermark had been stretched. Any idea to blend watermark with different resolution without stretching to video with transparency?
Here are the testing file. (ffmpeg version 3.1.2) https://drive.google.com/open?id=0B2X3VLS01TogdHVJZ2I1ZC1GUUU https://drive.google.com/open?id=0B2X3VLS01TogbjhuZTlBOFFpN1k
Use the lut filter before overlay
ffmpeg -y -i input.mp4 -i watermark.png -filter_complex
"[1]lut=a=val*0.3[a];[0][a]overlay=0:0"
-c:v libx264 -an output.mp4