Gif loses transpaent background when converted as video
-
Hi Yassine,
The MP4 format doesn't support alpha/transparency, so when you convert the GIF to MP4, a default (Black) background is added. If you request the output in a format that does support transparency such as WEBM, the transparent background is indeed retained:
https://res.cloudinary.com/yelouafi/image/upload/v1638453419/unnamed_rkewyz.webm
https://jsfiddle.net/stephencloudinary/znx92Loc/
If you want to show the asset in MP4 format on a webpage which has a specific color in the background, we don't support changing that black background directly currently.
As a workaround, you can use underlays of a specific background color, then add your GIF on top of that and return the result - for example this URL will fetch a gray placeholder from a third-party site and underlays it behind the semi-transparent GIF when making the video (your account security settings don't support unauthenticated fetching, so i've used our demo account): https://res.cloudinary.com/demo/image/fetch/u_fetch:aHR0cHM6Ly92aWEucGxhY2Vob2xkZXIuY29tLzE1MC9DMEMwQzAvRkZGRkZG,h_1.0,w_1.0,fl_relative/f_mp4/https://res.cloudinary.com/yelouafi/image/upload/unnamed_rkewyz.gif
Please let me know if that helps and if there's anything else I can help with
Regards,
Stephen
Please sign in to leave a comment.
Comments
1 comment