omega1
omega1

Reputation: 1052

ffmpeg multiple text/logo elements

I am trying to add multiple items to an ffmpeg command and am getting stuck.

So far in the command I am automatically updating one image, which I'm using as a video, I also want to add a logo and two lines of text.

I have been successful until the last item, which is the logo overlay.

This is the relevant part of code:

ffmpeg \
    -f image2 -loop 1 \
    -y \
    -i "/var/www/html/image_rotate.png" \
    -re \
    -i audio.mp3 \
    -vf "movie=/var/www/html/overlay_logo.png [watermark]; [in][watermark] overlay=0:0 [out], drawtext=fontsize=10:fontfile=/var/www/html/OpenSans-Regular.ttf:textfile=/var/www/html/text1.txt:box=1:boxcolor=#000000:fontcolor=#FFFFFF:x=0:y=(h-text_h-20):reload=1, drawtext=fontsize=10:fontfile=/var/www/html/OpenSans-Regular.ttf:textfile=/var/www/htmltext2.txt:box=1:boxcolor=#000000:fontcolor=#FFFFFF:x=0:y=(h-text_h-30)" \

This gives me the following error:

Simple filtergraph ... was expected to have exactly 1 input and 1 output. However, it had >1 input(s) and >1 output(s). Please adjust, or use a complex filtergraph (-filter_complex) instead.

If I remove the last part I added (the overlay logo) I do not get the error. If I add multiple -vf it only processes one (the text OR the logo).

I'm not sure how to achieve this.

Upvotes: 0

Views: 1728

Answers (1)

Gyan
Gyan

Reputation: 93299

When you need to work with multiple streams while filtering, the recommended method is to use a filter_complex.

ffmpeg \
    -loop 1 \
    -i "/var/www/html/image_rotate.png" \
    -i "/var/www/html/overlay_logo.png" \
    -i audio.mp3 \
    -filter_complex "[0][1]overlay=0:0,drawtext=fontsize=10:fontfile=/var/www/html/OpenSans-Regular.ttf:textfile=/var/www/html/text1.txt:box=1:boxcolor=#000000:fontcolor=#FFFFFF:x=0:y=(h-text_h-20):reload=1, drawtext=fontsize=10:fontfile=/var/www/html/OpenSans-Regular.ttf:textfile=/var/www/htmltext2.txt:box=1:boxcolor=#000000:fontcolor=#FFFFFF:x=0:y=(h-text_h-30)" \
    -y \
    -shortest \

The logo is now fed as a regular input.

Upvotes: 1

Related Questions