-1

Currently I am using three different commands to create three mp4s only to delete the two "temporary" videos using this code.

@ECHO OFF
ffmpeg -f lavfi -i color=size=1280x720:duration=5:rate=25:color=Black -vf "drawtext=fontfile='GothamRnd-Book.otf':line_spacing=15:fontsize=15:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text=Stack Exchange" "out1.mp4"
ffmpeg -i "out1.mp4" -i logo.png -filter_complex "overlay=x=10:y=10" "out2.mp4"
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 -i "out2.mp4" -c:v copy -c:a aac -shortest "out3.mp4"
del "out1.mp4"
del "out2.mp4"
pause

The nearest I have come is moving the anullsrc=channel_layout into the -filter_complex but that results in a long encode that I dont really understand what it is going because if I ctrl-c to cancel the batch still creates out3.mp4 correctly.

ffmpeg -f lavfi -i color=size=1280x720:duration=5:rate=25:color=Black -vf "drawtext=fontfile='GothamRnd-Book.otf':line_spacing=15:fontsize=15:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text=Stack Exchange" "out1.mp4"
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000  -i "out1.mp4" -i logo.png -filter_complex "overlay=x=10:y=10" "out3.mp4"

It seems like this could be streamlined to not create the temporary files. But maybe this is the only way to do this. Thank you for any assistance and sorry if the answer is obvious.

Rory

roar
  • 53
  • 6

1 Answers1

0

Use

ffmpeg -f lavfi -i color=s=1280x720:d=5:r=25:color=black -i logo.png -f lavfi -i anullsrc=cl=stereo:d=5:r=48000 -filter_complex "[0]drawtext=fontfile='GothamRnd-Book.otf':line_spacing=15:fontsize=15:fontcolor=white:x=(w-text_w)/2:y=(h-text_h)/2:text=Stack Exchange[vid];[vid][1]overlay=x=10:y=10" -c:v libx264 -c:a aac "out3.mp4"

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Did this work for you? I error:```[Parsed_anullsrc_0 @ 000002316c8a0b80] Option 'd' not found [lavfi @ 000002316c89aa80] Error initializing filter 'anullsrc' with args 'cl=stereo:r=48000:d=5' anullsrc=cl=stereo:r=48000:d=5: Option not found ``` and when I remove the duration option it becomes: ```[AVFilterGraph @ 000001c361d76f40] Unable to parse graph description substring: "]vid];[vid][1]overlay=x=10:y=10" Error initializing complex filters. Invalid argument ``` – roar Dec 18 '20 at 15:26
  • 1
    `]vid]` is a typo. Corrected. `d` in `anullsrc` is a new option. You'll need a recent git build. For older versions, you can add `-t 5` before `-i anullsrc`. – Gyan Dec 18 '20 at 15:34
  • That works now with the ```-t 5``` option. Do the ```-i``` inputs all have to defined before anything else? I've read about ```-map 0:v:0``` for streams but not ```[vid]```. This must be the ```-filter_complex``` mapping. Thanks again. – roar Dec 18 '20 at 17:32
  • 1
    re: `-i`, strictly no, but it's advised for clarity in commands. `[vid]` inside filtergraphs is a filter pad, See https://ffmpeg.org/ffmpeg-filters.html#Filtergraph-description – Gyan Dec 19 '20 at 07:23
  • Great. Thank you. – roar Dec 21 '20 at 10:37