ffmpeg transparent waveform and solid background - ffmpeg

Im trying to create waveform image with transparent wave and solid background color. Im find the similar topic here:
FFMPEG waveform transparent, background solid color
but the answer not working for me :(
Maybe do you know why this code suspend the program in console command.
ffmpeg -i input.mp3 -filter_complex \ "[0:a]aformat=channel_layouts=mono,compand=gain=-6, \
showwavespic=s=600x120:colors=white,negate[a]; \
color=red:600x120[c]; \
[c][a]alphamerge" -vframes 1 output.png

OK, so finally i do it in 3 steps
first generate black waveform on color solid background:
ffmpeg -y -i test.mp3 -f lavfi -i color=s=600x240:c=red -filter_complex "[0:a]showwavespic=s=600x240:colors=#000000[fg];[1:v][fg]overlay=format=rgb" -frames:v 1 output.png
We can use other background color(in hex) like c:0xC7C7C7
and next cute black wafevorm
ffmpeg -y -i output.png -vf colorkey=0x000000:0.6:0.2 Finished.png
and delete temp file
rm output.png
Thanks guys for help.

Related

Add image.png to top of image.jpg with ffmpeg became more dark

I try to create frame for picture use FFMPEG so its logic same as watermark. so i used this code
ffmpeg -i output_1920x1280.jpg -vf "movie=cpf-border.png [watermark]; [in][watermark] overlay=0:0 [out]" -q:v 1 withBorder.jpg
and try with diff command like this
ffmpeg -i output_1920x1280.jpg -i cpf-border.png -pix_fmt rgba -filter_complex "overlay=0:0" withBorder.jpg
but still same. there no error but the result of image its more dark. cause the frame base on white color so i saw that when do side by side can you help me maybe there another syntax to handle this or use another tools
It looks like there is some kind of bug related to YCbCr color space conversion.
We may select rgba format for each input before the overlay, and select rgb24 format after the overlay:
ffmpeg -y -i output_1920x1280.jpg -i cpf-border.png -filter_complex "[0]format=rgba[v1];[1]format=rgba[v2];[v1][v2]overlay=0:0,format=rgb24" -q:v 1 -src_range 0 -dst_range 1 withBorder.jpg
Result:

Trying to crop an image in ffmpeg using alphamerge but produces wrong alpha

I am using alphamerge in order to crop an image within a circle.
What I have so far is:
ffmpeg -f lavfi -i "color=c=white:size=240x240" -i avatar.png -i mask.png -filter_complex \
"[1][2]alphamerge[img]; \
[0][img]overlay[out]" -c:v png -map "[out]" -pix_fmt rgba -t 5 -y out.mp4 2>&1
with avatar.png and mask.png respectively being:
This produces the following output (1 frame of the output video):
which is unexpected, given the original input is much darker than this.
How can I crop the 'avatar.png' using the 'mask.png' so that the output is the avatar.png cropped in a circle and keeping the same alpha?
PS: The important bit here is for me to be able to crop the original image and maintaining the correct colors/apha of the original image. If there is an other way of doing this (other than alphamerge) I am happy to hear it.
Figured it out.
ffmpeg -i avatar.png -i mask.png -filter_complex "[0]scale=400:400[ava];[1]alphaextract[alfa];[ava][alfa]alphamerge" output.png

ffmpeg overlay video on image and remove video black background

Im using this ffmpeg command to overlay a video on image (with remove black background):
ffmpeg -loop 1 -i image.png -i video.mp4 -filter_complex [1:v]colorkey=0x000000:0.1:0.1[ckout];[0:v][ckout]overlay[out] -map [out] -t 5 -c:a copy -c:v libx264 -y result.mp4
But as you can see in the picture, the black parts of the ball have also disappeared. How can I solve this problem?
Not possible with colorkey/chromakey alone. The background is too similar to the color you want to remove. You have two options.
Mask
Use a mask. If the video comes with an alpha mask you can use it to cut out the background using the alphamerge filter:
ffmpeg -i bg.jpg -i video.mp4 -i alpha.mp4 -filter_complex "[1][2]alphamerge[alf];[0][alf]overlay" output.mp4
Use a different color
Replace the video that has a color that is different than the color you want to remove.

Overlay text in a background image not getting correct output

When overlaying a text or image(test.jpg) to a background image(bg.png),output video background color is getting darker.
here input image has an alpha value .
ffmpeg -loop 1 -i bg.png -i test.jpg -y -filter_complex "[0:v][1:v] overlay=25:25,-pix_fmt yuv420p" -shortest -t 10 tesy.mp4
Output excepted : https://i.stack.imgur.com/e5C3x.png
Output I got is
https://i.stack.imgur.com/reujS.png
If you see background color has huge differnce in the output I got
Below is the background image(bg.png) to which i am overlaying some image(test.jpg)
Use this image and overlay a test image, and let me know the difference in background color .
Add the premultiply filter for these particular PNG files:
ffmpeg -y -loop 1 -i bg.png -i test.jpg -filter_complex "[0]premultiply=inplace=1[bg];[bg][1:v]overlay=25:25:format=auto,format=yuv420p" -t 10 output.mp4
Or create the PNG with no alpha.
Or use the color filter to make the background:
ffmpeg -y -f lavfi -i color=c=purple:s=1280x720 -i test.jpg -filter_complex "[0][1]overlay=25:25:format=auto,format=yuv420p" -t 10 output.mp4

FFmpeg: Image scrolling, with green background?

Good morning, I hope you are well.
Please, I need help with the following...
I'm moving an image vertically, and I see that the background of the video is green.
How can I change this background color?
Example code:
ffmpeg -loop 1 -t 24 -i "image.jpg" -filter_complex "nullsrc=size=640x360[background];[background][0:v]overlay=shortest=1:y='min(0,-(t)*26)'" -qscale 1 -y out.mpg
Video Result: https://youtu.be/98rKLVO56wA
I hope I can help,
Thank you very much,
Greetings,
Hugo
Use
ffmpeg -loop 1 -t 24 -i "image.jpg" -filter_complex "color=000000:s=640x360[bg];[bg][0]overlay=shortest=1:y='min(0,-(t)*26)'" -qscale 1 -y out.mpg
The color filter takes RGB values as hex RRGGBB

Resources