I'm trying to actually programmatically add PNG overlay over h264 video.

Even though PNG image has alpha channel, after I apply filter, on a resulting video this image has black background instead of transparent one. Here's the filter:


I'm using openh264 to decode/encode video, so the pixel format of resulting video is YUV420P. I've tried to explicitly define format in filter:


But no change. ffmpeg: 3.4; openh264: Git (i.e. 1.9.0)

Thanks in advance.

Added: My PNG file: may be invisible on white background

  • Can you share the PNG? And your full command. – Gyan Jan 30 at 5:37
  • @Gyan I shared PNG. As for command - I'm doing everything programmatically. What important here is that my resulting video has YUV420p pixel format. – Pavel S. Jan 30 at 6:00
  • If you're using the C API, then this belongs on SO. overlay defaults to yuv420p, so all your format=rgba does is trigger lavfi to auto-insert a scaler to convert yuv420p to rgba. You need to examine the format of the overlay (secondary) input, to ensure the alpha is intact. The format of the main input isn't relevant. For verification, perform an overlay using the CLI (without any manual format filters added) and check. – Gyan Jan 30 at 6:23
  • Thanks, @Gyan. I've tried it from CLI (but with x264), and it worked just fine. So since overlay input is fine, any idea what may cause such problems? – Pavel S. Jan 30 at 6:45
  • Convert the secondary's format to yuva420p and then feed it to overlay. – Gyan Jan 30 at 6:58

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.