1

I'm a new user of FFmpeg, and I want to insert a logo on two videos (one video overlay another) with one command.

  1. FFmpeg command (ok):
ffmpeg -stream_loop -1 -i background1080p.mp4 -i input1080p.mp4 -i
logo.png -filter_complex
"[1]scale=1280:720[inner];[0][inner]overlay=70:70:shortest=1[vid];
[vid][2]overlay=10:10:enable='not(between(t\,10\,15))'[out]" -map
"[out]" -map 0:a -c:a copy -y -shortest output.mp4

Good result video When I use the above command, it works ok.

  1. FFmpeg command error

However, when I apply it to the command line below, I get an error:

@ECHO OFF
Setlocal EnableDelayedExpansion
set INPUT=D:\Shorts\code\INPUT
set OUTPUT=D:\Shorts\code\OUTPUT

:: encode video:

for %%a in ("%INPUT%\*.*") DO ffmpeg -i "%%a" -stream_loop -1 -i background.mp4 -i logo.png -filter_complex "[1]scale=1280:720[inner];[0][inner]overlay=70:70:shortest=1[vid]; [vid][2]overlay=10:10:enable='not(between(t\,10\,15))'[out]" -map "[out]" -map 0:a -c:a copy -shortest "%output%\%%~na_%%03d.mp4"

pause

Wrong overlay result

  • Main video (from INPUT folder) video and background.mp4 have their roles the other way round and what's supposed to be the overlay is the background.

Please help me fix the error

1 Answer 1

1

Swap the order of the first two inputs i.e. -stream_loop -1 -i background.mp4 -i "%%a"

2
  • I have a question, can you help? Specifically: with the above code, I want to insert a green video file (this green video file is also looped on "main video" - (colorkey=0x00ff00:0.3:0.2) So what do we have to deal with?
    – alexdo
    Commented Jul 6, 2023 at 16:24
  • 1
    Post a new question for that.
    – Gyan
    Commented Jul 7, 2023 at 3:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .