Add line to FFMPEG waveform without a background - ffmpeg

I am trying to write an ffmpeg command to generate a waveform from audio. I've managed to generate the waveform but I fail when trying to add a line such that the silent areas are not blank.
Currently the command is:
-filter_complex "[0:a]aformat=channel_layouts=mono,compand=attacks=0:points=-80/-900|-45/-15|-27/-9|0/-7|20/-7:gain=15,showwavespic=s=180x26:colors=#7c84cc[fg];color=s=180x26:color=#303030[bg];[bg][fg]overlay=format=auto,drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=1:color=#7c84cc" -frames:v 1
I have added some tweaks of my own to boost the visual appeal but what I would like is to use the drawbox without the color filter. If I try to do that the line disappears during the silent part.
I have also attempted to use a transparent image as the background but that failed as well.
I have relied heavily on this question when approaching this problem
Generating a waveform using ffmpeg

One option would be to use the gradients filter, to add a changing colour gradient.
e.g.
ffmpeg -i input.mp3 -filter_complex "gradients=s=vga:c0=303030:c1=7c84cc:x0=0:x1=0:y0=0:y1=640 [bg];[0:a]showwaves=mode=p2p:s=vga:split_channels=1:scale=lin:draw=scale:colors=Yellow|White[v];[bg][v]overlay=shortest=1:format=rgb:alpha=premultiplied [vid]" -map "[vid]" -map 0:a -vsync vfr -preset ultrafast -f matroska - | ffplay -autoexit -
There is a speed parameter as well to adjust the gradient rotation.

Related

ffmpeg transparent background with colorkey shows background bleeding

I am creating a video with transparent background video with the following command. After creation I want to overlay this video on another video
ffmpeg -f lavfi -i color=red:s=1920x1080,colorkey=red,format=rgba -loop 1 -t 0.08 -i "CreditWhite.png" -filter_complex "[1:v]scale=1920:-2,setpts=if(eq(N\,0)\,0\,1+1/0.02/TB),fps=60[fg]; [0:v][fg]overlay=y=-'t*h*0.02':eof_action=endall[v]" -map "[v]" -pix_fmt yuva444p10le -vcodec prores_ks credits.mov
Creating the video works fine but when I overlay this on another video (using openshot) I get a lot of color bleeding of the background colour around the edges. Any suggestions to improve the ffmpeg prompt to stop this from happening? I tried very slightly increasing the opacity (0.06) as mentioned in another thread without success.
Video uploaded to youtube for reference
UPDATE
Using different colours had the same effect

How can I resize an overlay image with ffmpeg?

I am trying to add an overlay to a video using the following command
ffmpeg -y -i "$videoPath" -i "$overlayPath" -filter_complex "[0:v] [1:v] overlay=$overlayPosition" -pix_fmt yuv420p -c:a copy "$outputPath"
However, I would like to be able to resize the overlay I am about to apply to some arbitrary resolution (no care for keeping proportions). However, although I followed a couple of similar solutions from SO (like FFMPEG - How to resize an image overlay?), I am not quite sute about the meaning of the parameters or what I need to add it in my case.
I would need to add something like (?)
[1:v]scale=360:360[z] [1:v]overlay=$overlayPosition[z]
This doesn't seem to work so I'm not sure what I should be aiming for.
I would appreciate any assistance, perhaps with some explanation.
Thanks!
You have found all parts. Let's bring them together:
ffmpeg -i "$videoPath" -i "$overlayPath" -filter_complex "[1:v]scale=360:360[z];[0:v][z]overlay[out]" -map "[out]" -map "0:a" "$outputPath"
For explanation:
We're executing here two filter within the "filter_complex" parameter separated by a semicolon ";".
First we scale the second video input ([1:v]) to a new resolution and store the output in variable "z" (you can put here any name).
Second we bring the first input video ([0:v]) and the overlay ([z]) together and store the output in variable "out".
Now it's time to tell ffmpeg what he should pack into our output file:
-map "[out]" (for the video)
-map "0:a" (for the audio of the first input file)

ffmpeg how to place still image over full vstack?

Im trying to build a simple video editor and im using ffmpeg on the background. I want as much different filters/properties in one command but im not succeeding in placing a still image before everything else (first frame). I want a vstack after the image has shown in a video.
I tried a lot of different commands etc. and most of the time the video renders but the image included in the vstack, or the video doesn't start for the amount of seconds I want the still image to be shown.
ffmpeg -hide_banner -i "header.jpg" -i "video.mp4" -i "footer" -i "still-image.jpg" -filter_complex "[1][3]overlay=0:0:enable='between(t,0,4)';vstack=inputs=3" -pix_fmt yuv420p -c:a copy -y output.mp4
Most of the time I don't get an error. It just isn't doing what's expected. The above command is one of the many I tried but is basically what I want. Can someone help please?
There are several ways to do this. This method delays the vstack and overlays still-image.jpg during the delay.
ffmpeg -i "header.jpg" -i "video.mp4" -i "footer.jpg" -i "still-image.jpg" -filter_complex "[0][1][2]vstack=inputs=3[v0];[v0]tpad=start_duration=4[bg];[bg][3]overlay=(W-w)/2:(H-h)/2:enable='between(t,0,4)',format=yuv420p[v];[1:a]adelay=4s:all=true[a]" -map "[v]" -map "[a]" output.mp4
Requires FFmpeg 4.2 or newer.

overlay audio volume histogram over static image

I'm actually working to a project for music video generation using ffmpeg.
I'd like to know if it's possibile to use ffmpeg itself or a combination of command line component under windows environment to make a visualization of audio spectrum (ahistogram ?) over a static background image like the one I found on the web:
Any ideas or coding tips?
ffmpeg -loop 1 -i background.png -i music.mp3 -filter_complex "[1]ahistogram=s=789x50:rheight=1[fg];[0][fg]overlay=(W-w)/2:H-h-10:shortest=1,scale='iw-mod(iw,2)':'ih-mod(ih,2)',format=yuv420p[v]" -map "[v]" -map 1:a -movflags +faststart output.mp4
Not exactly what you want, there is no option to create bars as in your image, but perhaps this will be good enough. See the ahistogram filter documentation for more options.

Which filter should be used when i want to add watermark to a video?

Hi everyone,
I want to add a watermark to a video use a picture.
here is the problem
and this is my command:
c:\ffmpeg.exe -y -i c:\ffmpeg\input\walk.mp4 -acodec copy -b 300k -vf "movie=w1.jpg [watermark];[in][watermark] overlay=5:5 [out]" c:\ffmpeg\output\walk.mp4
What am I doing wrong?
You can use the overlay filter, but first you need to use a recent build because the version you are using is considered to be absolutely ancient due to how active the FFmpeg project is. You can get builds for Windows at Zeranoe FFmpeg builds.
Now that you are not using a graybeard ffmpeg here is the most basic example:
ffmpeg -i background.avi -i watermark.jpg -filter_complex overlay output.mp4
The overlay filter documentation will show how to position the watermark. This example will place the watermark 10 pixels from the bottom right corner of the main video and copy your audio as in your example:
ffmpeg -i background.avi -i watermark.jpg -filter_complex overlay=main_w-overlay_w-10:main_h-overlay_h-10 -codec:a copy output.mp4

Resources