FFMPEG picture in picture and watermark - ffmpeg

I'm trying to take create a picture in picture effect with 2 videos and add a watermark with 1 command. Here's what I have so far, it works great, except the watermark is on the picture in picture video, not the main background video. How do I make the watermark on the main video?
ffmpeg -y -i pip.mp4 -i main.mp4 -i logo.png -filter_complex \
"[0]scale=iw/4:-1[pip]; \
[pip][2]overlay=10:10[watermark]; \
[1][watermark]overlay=main_w-overlay_w-10:main_h-overlay_h-10" output.mp4

Rearrange your labels:
ffmpeg -y -i pip.mp4 -i main.mp4 -i logo.png -filter_complex \
"[0]scale=iw/4:-1[pip]; \
[1][pip]overlay=10:10[watermark]; \
[watermark][2]overlay=main_w-overlay_w-10:main_h-overlay_h-10" output.mp4

Related

overlay multiple images on a video with specific time per image and repeat (loop) the process the images until video end

I am trying to making video with ffmpeg where I want to overlay images on a video.
I want to show the image for 5 secound each and want to the process to loop until the video end.
I am using following commend which working perfectly but want to modify to loop the images.
ffmpeg -y -i long_process/2-scrolling.mp4 \
-i upload-images/040820221255452.png \
-i upload-images/040820221255453.png \
-filter_complex "[0:v][1:v]overlay=75:(H-h)/2:enable='between(t, 1, 5)'[v0]; \
[v0][2:v]overlay=75:(H-h)/2:enable='between(t, 5, 10)'" \
-c:a copy long_process/output.mp4
I am very new to ffmpeg looking for help from you.
Thanks in advance
I got the answer
ffmpeg -y -i long_process/2-scrolling.mp4 -framerate 1/3 -pattern_type glob -loop 1 -i 'tools/*.png' \
-filter_complex "[0]overlay=75:(H-h)/2:shortest=1" \
-r 60 -c:a copy long_process/output.mp4

How to overlay a video on another video and also fade in a PNG

I am looking to overlay a video on top of another video and then also add a fade in and fade out PNG.
I have the current command which works perfectly in merging two video files one on top of the other.
ffmpeg -y -i output.mp4 -i transparent.mp4 -filter_complex "[1:v][0:v]scale2ref[ua][b];[ua]setsar=1,format=yuva444p,colorchannelmixer=aa=.7[u];[b][u]overlay=eof_action=pass[v]" -map [v] awsome.mp4
I need to now add a PNG on it as well that fades in at 1s and fades out at 9.5s.
Appreciate any and all advice.
Use
ffmpeg -y -i output.mp4 -i transparent.mp4 -loop 1 -t 10 -i image.png -filter_complex "[1:v][0:v]scale2ref[ua][b];[ua]setsar=1,format=yuva444p,colorchannelmixer=aa=.7[u];[b][u]overlay=eof_action=pass[v];[2]fade=in:st=0:d=1:alpha=1,fade=out:st=8.5:d=1:alpha=1[i];[v][i]overlay[v]" -map [v] awsome.mp4
If the PNG needs to be scaled to video size, use scale2ref for the image as well.
ffmpeg -y -i output.mp4 -i transparent.mp4 -loop 1 -t 10 -i image.png -filter_complex "[1:v][0:v]scale2ref[ua][b];[ua]setsar=1,format=yuva444p,colorchannelmixer=aa=.7[u];[b][u]overlay=eof_action=pass[v];[2][v]scale2ref[i][v];[i]fade=in:st=0:d=1:alpha=1,fade=out:st=8.5:d=1:alpha=1[i];[v][i]overlay[v]" -map [v] awsome.mp4

ffmpeg How to make timed picture overlay changes that repeat

Hello I am working to figure out how to make it so that my live stream has logos that change into another logo every 20 seconds currently all I have been able to figure out is how to enable them at a certain time like this.
ffmpeg -re -i "https://d2zihajmogu5jn.cloudfront.net/bipbop-advanced/bipbop_16x9_variant.m3u8" -i ./public/images/ACE.png -i ./public/images/logo2.jpg -i ./public/images/crunchy.png -i ./public/images/red.jpg -filter_complex \
"[0]scale=1290:720,setsar=1[ovrl0]; \
[1]scale=40:40[ovrl1]; \
[2]scale=40:40[ovrl2]; \
[3]scale=40:40[ovrl3]; \
[4]scale=40:40[ovrl4]; \
[ovrl0][ovrl1] overlay=x=(main_w-overlay_w)/1.025:y=(main_h-overlay_h)/18:enable='lt(mod(t,40),10)'[v1]; \
[v1][ovrl2] overlay=x=(main_w-overlay_w)/1.025:y=(main_h-overlay_h)/18:enable='between(mod(t,40),10,20)'[v2]; \
[v2][ovrl3] overlay=x=(main_w-overlay_w)/1.025:y=(main_h-overlay_h)/18:enable='gt(mod(t,40),20)'[v3]; \
[v3][ovrl4] overlay=x=(main_w-overlay_w)/1.025:y=(main_h-overlay_h)/18:enable='gt(mod(t,40),30)'" -acodec aac -vcodec libx264 -f flv "rtmp://a.rtmp.youtube.com/live2/2222-2222-2222-2222"
Set enable for first logo overlay to lt(mod(t,40),20), and for 2nd logo overlay to gte(mod(t,40),20).
This will show 1st logo at t = 0-20,40-60,80-100.. and 2nd logo at t = 20-40,60-80,100-120..

Combining multiple image files into a video while using filter_complex to apply a watermark

I'm trying to combine two ffmpeg operations into a single one.
Currently I have two sets of ffmpeg commands that first generate a video from existing images, then runs that video through ffmpeg again to apply a watermark.
I'd like to see if its possible to combine these into a single operation.
# Create the source video
ffmpeg -y \
-framerate 1/1 \
-i layer-%d.png \
-r 30 -vcodec libx264 -preset ultrafast -crf 23 -pix_fmt yuv420p \
output.mp4
# Apply the watermark and render the final output
ffmpeg -y \
-i output.mp4 \
-i logo.png \
-filter_complex "[1:v][0:v]scale2ref=40:40[a][b];[b][a]overlay=(80):(main_h-200-80)" \
final.mp4
Use
ffmpeg -y \
-framerate 1/1 -i layer-%d.png \
-i logo.png \
-filter_complex "[0:v]fps=30[img];
[1:v][img]scale2ref=40:40[a][b];[b][a]overlay=(80):(main_h-200-80)" \
final.mp4
(The use of scale2ref doesn't make sense since you're scaling to a fixed size).

Adding more than one image in front of video in ffmpeg

I'm using this command to put image in fromt of video in ffmpeg:
ffmpeg -re -i input -i myimage -filter_complex "overlay=10:10" -f mpegts udp://127.0.0.1:port
I need to put another image in differant position but on the same video, is there any way to do it ?
You would use
ffmpeg -re -i input -i image1 -i image2 \
-filter_complex "[0][1]overlay=10:10[a];[a][2]overlay=W-10:10" \
-f mpegts udp://127.0.0.1:port

Resources