FFMPEG: Controlling overlay through ZeroMQ in ffmpeg

Viewed 1913

For a project we need to manually control an overlay (static image) on top of a video stream. We concluded that we will need ZeroMQ to control this, and we've managed to control an audio filter successfully through ZeroMQ.

To achieve this we've considered two options:

  1. Use a color filter to control the foreground (image) transparency
  2. "Move" the overlay image in front of the video stream, and remove it out of the video canvas

We've managed to get both working, but not in combination with ZeroMQ, unfortunately.

Example:

ffmpeg -loglevel verbose    \
              -i $STREAM     \
              -i overlay.png  \
          -bsf:a aac_adtstoasc \
        -threads 12             \
             -vf "zmq=bind_address=tcp\\\://127.0.0.1\\\:1235, [0:v][1:v]overlay=25:25" \
            -c:a aac              \
             -af "azmq=bind_address=tcp\\\://127.0.0.1\\\:1235,volume=1" \
            -c:v h264 output

The above example produces the following error:

Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument

Advice on how this can be achieved is highly appreciated!

1 Answers

THE WORKING SOLUTION :


UPDATE
Managed to get it working :

ffmpeg -loglevel verbose    \
              -i $STREAM     \
              -i overlay.png  \
          -bsf:a aac_adtstoasc \
        -threads 12             \
 -filter_complex "[0:v][1:v]overlay=x=0:y=0,zmq=bind_address=tcp\\\://127.0.0.1\\\:1236" \
            -c:a aac              \
             -af "azmq=bind_address=tcp\\\://127.0.0.1\\\:1235,volume=1" \
            -c:v libx264

And I can remove (control) the overlay by sending a message through ZeroMQ:

Parsed_overlay_0 x 1280
Related