ffmpeg combine 3 filter_complex commands - ffmpeg

Can anyone help me. I want to combine 3 ffmpeg commands:
1:
ffmpeg -y -i input.mp4 -vf scale=720:-2,setsar=1:1 -c:v libx264 -preset ultrafast -c:a copy out1.mp4
2:
ffmpeg -i out1.mp4 -filter_complex '[0:v]crop=$url_width_:$barik:$url_width_:$url_height_, boxblur=10[fg]; [0:v]crop=$url_width_:$barik:0:0,boxblur=10[fg2]; [0:v][fg]'overlay=0:$blur_y'[bg]; [bg][fg2]overlay=0:0' -preset ultrafast -c:a copy out2.mp4
3:
ffmpeg -i out2.mp4 -i $wmf -filter_complex '[1]scale=iw*$scale:-1[wm];[0][wm] overlay=$pos' -preset ultrafast -codec:a copy final.mp4
Please help me to combine this commands to one command.

As follows:
ffmpeg -i input.mp4 -i $wmf -filter_complex '[0:v]scale=720:-2,split=3[v0][fg][fg2];[fg]crop=$url_width_:$barik:$url_width_:$url_height_, boxblur=10[fg]; [fg2]crop=$url_width_:$barik:0:0,boxblur=10[fg2];[v0][fg]'overlay=0:$blur_y'[bg]; [bg][fg2]overlay=0:0[v0];[1]scale=iw*$scale:-1[wm];[v0][wm] overlay=$pos' -preset ultrafast -c:a copy final.mp4

Related

How to combine this 2 ffmpeg commands?

I need to combine this 2 ffmpeg commands:
"-i videoFile.mp4 -c:a copy -c:v libx264 -vf pad=$length:height=$length:x=-1:y=-1:color=#195766 resultFile"
and
"-i videoFile.mp4 -i waterMark.png -filter_complex 'overlay=10:main_h-overlay_h-10' resultFile.mp4"
Is it possible? How result command will look like?
I hope I have got it right...
The combined command is:
ffmpeg -y -i videoFile.mp4 -i waterMark.png -c:a copy -c:v libx264 -filter_complex "[0:v]pad=384:height=216:x=-1:y=-1:color=#195766[t];[t][1:v]overlay=10:main_h-overlay_h-10[v]" -map "[v]" -map 0:a resultFile.mp4
For mobile FFmpeg on android (according to OP's comment):
"-y -i ${videoFile.absolutePath} -i $waterMarkPath -c:a copy -c:v libx264 -filter_complex pad=$length:height=$length:x=-1:y=-1:color=#195766[t];[t][1:v]overlay=10:main_h-overlay_h-10[v] -map [v] -map 0:a ${resultFile.absolutePath}"
I used the following post as reference: Create video with 5 images with fadeIn/out effect in ffmpeg.
Testing:
Creating a sample video file (with audio):
ffmpeg -y -r 25 -f lavfi -i testsrc=size=192x108:rate=30 -f lavfi -i sine=frequency=400 -f lavfi -i sine=frequency=1000 -filter_complex amerge -vcodec libx265 -crf 17 -pix_fmt yuv420p -acodec aac -ar 22050 -t 30 videoFile.mp4
Creating a sample PNG image file:
ffmpeg -y -f lavfi -i mandelbrot=rate=1:size=192x108 -t 1 waterMark.png
Executing the combined command:
ffmpeg -y -i videoFile.mp4 -i waterMark.png -c:a copy -c:v libx264 -filter_complex "[0:v]pad=$length:$length=216:x=-1:y=-1:color=#195766[t];[t][1:v]overlay=10:main_h-overlay_h-10[v]" -map "[v]" -map 0:a resultFile.mp4
Result (first frame of the output of the test):

ffmpeg: overlay multiple images to a video

In order to overlay a single image to a video, I can do:
ffmpeg -i vid00.mp4 -i img00.png -filter_complex "[0:v][1:v]overlay=0:0:enable='between(t, 1, 2)'" -c:v libx264 -preset ultrafast -qp 20 -c:a copy -y vid01.mp4
How can I overlay multiple images to a video in a single ffmpeg call?
I've tried stuff like:
ffmpeg -i vid00.mp4 -i img00.png -i img01.png -filter_complex "\
[0:v][1:v]overlay=0:0:enable='between(t, 1, 2)'[v0]; \
[2:v][3:v]overlay=0:0:enable='between(t, 3, 4)'[v1]; \
[v0][v1]concat=n=2:v=1:a=0,format=yuv420p[v]" -map "[v]" -map 0:a -c:v libx264 -preset ultrafast -qp 20 -c:a copy -y vid01.mp4
and variations thereof (by messing with the [0:v][1:v] indices), but to avail.,
Combined command:
ffmpeg -i vid00.mp4 -i img00.png -i img00.png -filter_complex "[0:v][1:v]overlay=0:0:enable='between(t, 1, 2)'[v0];[v0][2:v]overlay=0:0:enable='between(t, 3, 4)'" -c:v libx264 -preset ultrafast -qp 20 -c:a copy -y vid01.mp4

Combining 2 FFMPEG Commands

I'm trying to combine 2 ffmpeg commands, one which creates the video, and another which adds a simple fade to the beginning of the created video. Here's what I have:
ffmpeg -y -stream_loop -1 -i "video.mp4" -stream_loop -1 -i "music.mp3" -i "audio.mp3" -filter_complex "[1:a]volume=0.1[a1];[2:a]adelay=5000|5000,apad=pad_dur=10[a2];[a1][a2]amerge=inputs=2,afade=in:st=0:d=5[audio]" -map "0:v" -map "[audio]" -c:v libx264 -c:a aac -ac 2 -ar 22050 -preset veryfast -shortest "output.mp4"
ffmpeg -y -i "output.mp4" -filter_complex "[0:v]fade=in:0:d=5" -c:a copy -preset veryfast -movflags faststart -fflags genpts "done.mp4"
The two commands work perfectly fine, however the second one takes about the same amount of time to process as the first, and I feel it should be relatively easy to do the fade-in during the first encode. For my skillset atleast, I was wrong. Please could someone with more experience lend a helping hand?
Thanks.
Add a simple filterchain for the video.
ffmpeg -y -stream_loop -1 -i "video.mp4" -stream_loop -1 -i "music.mp3" -i "audio.mp3" -filter_complex "[1:a]volume=0.1[a1];[2:a]adelay=5000|5000,apad=pad_dur=10[a2];[a1][a2]amerge=inputs=2,afade=in:st=0:d=5[audio]" -vf "fade=in:0:d=5" -map "0:v" -map "[audio]" -c:v libx264 -c:a aac -ac 2 -ar 22050 -preset veryfast -shortest -movflags faststart "done.mp4"

FFMPEG Add watermark to MP4

I have this command to add watermark to an mp4
ffmpeg -i junai-blvaz.mp4 -i evercam-logo-white.png -filter_complex "[1]scale=iw/2:-1[wm];[0][wm]overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10" -codec:a copy output.mp4
But I am creating the video using
ffmpeg -r 6 -i /tmp/%d.jpg -c:v h264_nvenc -r 6 -preset slow -bufsize 1000k -pix_fmt yuv420p -y junai-blvaz.mp4
Is there any way to merge this command of adding watermark
-i evercam-logo-white.png -filter_complex '[1]scale=iw/2:-1[wm];[0][wm]overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10'
to the very first command through which mp4 video has been created?
Combine the two commands:
ffmpeg -y -framerate 6 -i /tmp/%d.jpg -i evercam-logo-white.png -filter_complex "[1]scale=iw/2:-1[wm];[0][wm]overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10,format=yuv420p" -c:v h264_nvenc -preset slow -bufsize 1000k junai-blvaz.mp4

Can I combine these 2 commands? (or am I fighting a losing battle?)

I'm very new to ffmpeg but so far I'm enjoying it. But I'm stuck on something. I want to combine these two commands into one, something I'm sure must be possible, but after countless hours and no luck, here I am :)
ffmpeg -y -f concat -safe 0 -protocol_whitelist "file,http,https,tcp,tls" -i "tmp.images.txt" -i "tmp.audio.mp3" -filter_complex "drawbox=y=ih-38:color=black#0.6:width=iw:height=38:t=fill, drawtext=fontfile=Assets/calibrib.ttf:text='%%~ni':fontcolor=white:fontsize=14:x=(w-tw)/2:y=(h)-24" -c:v libx264 -preset veryfast -tune stillimage -shortest -pix_fmt yuv420p "tmp.slide.mp4"
ffmpeg -loop 1 -framerate 2 -i "Assets/studio.jpg" -i tmp.slide.mp4 -filter_complex "[1]scale=879:496[inner];[0][inner]overlay=207:49:shortest=1[out]" -map "[out]" -map 1:a -c:a aac -y tmp.output.mp4
the first line creates a slideshow and places text at bottom
the second line takes the slideshow video and inserts it into a background image before outputting final video
Use
ffmpeg -y -f concat -safe 0 -protocol_whitelist "file,http,https,tcp,tls" -i "tmp.images.txt" -i "tmp.audio.mp3" -i "Assets/studio.jpg" -filter_complex "[0]drawbox=y=ih-38:color=black#0.6:width=iw:height=38:t=fill, drawtext=fontfile=Assets/calibrib.ttf:text='%%~ni':fontcolor=white:fontsize=14:x=(w-tw)/2:y=(h)-24,scale=879:496[inner];[2][inner]overlay=207:49" -c:v libx264 -preset veryfast -tune stillimage -c:a aac -shortest -pix_fmt yuv420p "tmp.slide.mp4"

Resources