ffmpeg overlay filter adds black background for PNG with transparency
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:
[in][in2]overlay=15:15[out]
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:
[in][in2]overlay=15:15,format=rgba,format=yuv420p[out];
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
video ffmpeg images h.264 overlay
|
show 4 more comments
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:
[in][in2]overlay=15:15[out]
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:
[in][in2]overlay=15:15,format=rgba,format=yuv420p[out];
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
video ffmpeg images h.264 overlay
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 yourformat=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
|
show 4 more comments
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:
[in][in2]overlay=15:15[out]
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:
[in][in2]overlay=15:15,format=rgba,format=yuv420p[out];
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
video ffmpeg images h.264 overlay
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:
[in][in2]overlay=15:15[out]
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:
[in][in2]overlay=15:15,format=rgba,format=yuv420p[out];
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
video ffmpeg images h.264 overlay
video ffmpeg images h.264 overlay
edited Jan 30 at 5:59
Pavel S.
asked Jan 30 at 2:53
Pavel S.Pavel S.
11
11
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 yourformat=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
|
show 4 more comments
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 yourformat=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
Can you share the PNG? And your full command.
– Gyan
Jan 30 at 5:37
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
@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
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
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
Convert the secondary's format to yuva420p and then feed it to overlay.
– Gyan
Jan 30 at 6:58
|
show 4 more comments
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1399921%2fffmpeg-overlay-filter-adds-black-background-for-png-with-transparency%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1399921%2fffmpeg-overlay-filter-adds-black-background-for-png-with-transparency%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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