I generate a video from png images using
ffmpeg -i visualization/%d.png -c:v libx264 -vf "scale=500:trunc(ow/a/2)*2" -pix_fmt yuv420p z.mov
and if images have transparencies, they become black. Can I somehow make them white?
Before running ffmpeg, use ImageMagick to "flatten" each PNG against white.
mogrify -background white -flatten visualization/*.png
Related
I'm converting a PNG to JPG. The transparent background turns black by default. I need it to be white.
What is the FFmpeg command to set the alpha channel to a color?
I think it has something to do with the alphamerge and alphaextract Filters.
ffmpeg -i image.png -qscale:v 2 image.jpg
This replaces white with transparency when converting to png:
-vf chromakey=white
You can use the geq filter.
ffmpeg -i in.png -vf format=yuva444p,geq='if(lte(alpha(X,Y),16),255,p(X,Y))':'if(lte(alpha(X,Y),16),128,p(X,Y))':'if(lte(alpha(X,Y),16),128,p(X,Y))' out.jpg
If your alpha is a pure black and white image, change 16 to 1.
I am trying to convert a mp4 video with a completely uniform pink color to a mov file seuch that the pink color is transparent.
I have run:
ffmpeg -i input.mp4 -vf "chromakey=0xf25b98:0.01:0" -c copy -c:v png output.mov
I confirmed that #f25b98 is the color I am replacing. This makes absolutely nothing transparent. When I try:
ffmpeg -i input.mp4 -vf "chromakey=0xf25b98:0.02:0" -c copy -c:v png output.mov
I get some weird transparent dots in my pink but still nothing is changed (see attached screenshot from video).
Why would ffmpeg exhibit this behavior?
Short answer is that it is not possible to use FFMPEG to remove a keyframe from an already compressed video stream because the compression introduces bleed which makes for an imprecise transparency.
I have a .mov video with alpha channel and .png watermark. Is it possible to overlay watermark only over the non-transparent pixels of the video using ffmpeg?
Use
ffmpeg -i in.mp4 -i image \
-filter_complex "[0]split[o][a];[a]alphaextract[a];\
[o][1]overlay=format=auto[oc];[oc][a]alphamerge" -c:a copy out.mov
Choose a codec that preserves alpha like -c:v png.
I'm converting a PNG to JPG. The transparent background turns black by default. I need it to be white.
What is the FFmpeg command to set the alpha channel to a color?
I think it has something to do with the alphamerge and alphaextract Filters.
ffmpeg -i image.png -qscale:v 2 image.jpg
This replaces white with transparency when converting to png:
-vf chromakey=white
You can use the geq filter.
ffmpeg -i in.png -vf format=yuva444p,geq='if(lte(alpha(X,Y),16),255,p(X,Y))':'if(lte(alpha(X,Y),16),128,p(X,Y))':'if(lte(alpha(X,Y),16),128,p(X,Y))' out.jpg
If your alpha is a pure black and white image, change 16 to 1.
I have some FLV videos with alpha channels, and I want to convert each of them to PNG images using ffmpeg but keep the transparency.
So far, I've tried this:
ffmpeg -i input.flv -an -y %d.png
But this outputs the PNG files with black background.
Is there any way to do this?
Alternate acceptable solution: If I can output the images and give the alpha channel a certain color of my choice. I can then remove it later via imagemagick and convert that color to transparency.
I know its quite late for an answer but I was searching for a similar solution and found this : ffmpeg -i video.flv -r 25 -vcodec png -pix_fmt rgb32 %d.png