overlay audio volume histogram over static image - 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.

Related

Add line to FFMPEG waveform without a background

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.

FFMPEG script to merge multiple videos and a background image

I have 30 clips which are different in aspect ratio(like some videos are 10801920(they are vertical) and some are 1280720(horizontal aspect ratio videos). I want to merge all of them but also have a static background image that is of 1920x1080 aspect ratio. The video would be such that all the clips are concatenated but they have a background image(just like those tiktok compilation videos on youtube). Can someone please help me with this program?
Example using 3 videos. It can easily be expanded to 30 videos. I broke the command into multiple lines so you can see the syntax better. Make it one line before executing.
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i image.png -filter_complex
"[0:v]scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720,setsar=1,fps=25,format=yuv420p[v0];
[1:v]scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720,setsar=1,fps=25,format=yuv420p[v1];
[2:v]scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720,setsar=1,fps=25,format=yuv420p[v2];
[0:a]aformat=sample_rates=44100:channel_layouts=stereo[a0];
[1:a]aformat=sample_rates=44100:channel_layouts=stereo[a1];
[2:a]aformat=sample_rates=44100:channel_layouts=stereo[a2];
[v0][a0][v1][a1][v2][a2]concat=n=3:v=1:a=1[vid][a];
[3][vid]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[v]"
-map "[v]" -map "[a]" -c:v libx264 -c:a aac -movflags +faststart output.mp4
References:
How to concatenate videos in ffmpeg with different attributes?
How to center overlay in ffmpeg?
Resizing videos with ffmpeg to fit specific size

FFMPEG curtain effect slideshow from images

I have bunch of images that i have to convert to slideshow with curtain effect. currently i am running this command that convert images to video.
ffmpeg -r 1/5 -i img%d.png -c:v libx264 -vf "fps=25,format=yuv420p" video.mp4
But how to achieve this kind of effect with ffmpeg. Image link Required result
I searched online but not found any solution. I have clue of alpha mask but no idea how to use it for such result.
ffmpeg -y -i img1.png -i img2.png -i img3.png -filter_complex "[0:v]zoompan=z='zoom+0.0000':d=50[img1];[1:v]zoompan=z='if(lte(zoom,1.0),1.1,max(1.001,zoom-0.0030))':d=200[img2];[img1][img2]blend=all_expr='if(lte((H/2-sqrt((Y-H/2)*(Y-H/2)))+N*8*SH,H/2),A,B)'[img1img2];[1:v]zoompan=z='zoom+0.0000':d=50[img2];[2:v]zoompan=z='if(lte(zoom,1.0),1.1,max(1.001,zoom-0.0030))':d=200[img3];[img2][img3]blend=all_expr='if(lte((H/2-sqrt((Y-H/2)*(Y-H/2)))+N*8*SH,H/2),A,B)'[img2img3];[img1img2][img2img3]concat=n=2[final]" -map "[final]" out.mp4
This ffmpeg command will generate door open (curtain) effect.
Here is logic.
Suppose you have there images you want to create this effect. First create blend effect of first img1 and img2. Then create another blend effect with img2 and img3. then merge these 2 generated videos.

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.

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