I'm working on a project for a tabletop video stream. The goal is to be able to show card animations overlaid on the stream using voice commands. When I first searched for how to accomplish this, I found pylivestream (using ffmpeg) to actually stream to various sites. I did also get a solution for the voice commands. Now I'm just trying to figure out how to add animations to a live stream.
I have been able to accomplish two things:
- Overlay text on the stream - pretty sure I know how to update that live if I need to, so that'll be useful
- Overlay a video on the stream. I didn't do anything fancy with this, just placed the video in the top left corner of the stream. And it starts at the same time as the stream. Here is the ffmpeg command I ended up with:
ffmpeg -loglevel verbose -y -f gdigrab -s 2056x1080 -offset_x 0 -offset_y 0 -i desktop -f dshow -i audio="Headset (WH-1000XM4 Hands-Free AG Audio)" -codec:v libx264 -pix_fmt yuv420p -preset veryfast -b:v 3000k -g 60 -codec:a aac -b:a 128k -ar 44100 -filter_complex "[0:v]setpts=PTS-STARTPTS[v0];movie=movie.mov:s=dv[overv];[overv]setpts=PTS-STARTPTS+0/TB[v1];[v0][v1]overlay=0:0:eof_action=pass[out1]" -map "[out1]" -maxrate 3000k -bufsize 1500k -strict experimental -f flv "rtmp://localhost"
I'm wondering if I can extend #2 to be able to dynamically load videos. In my case, these videos would be a card animation. I read something about playlists but there didn't seem to be an obvious solution for my use case.
It has also been recommended to me to use an ffmpeg API. I did start doing some research on this, mostly with
ffmpeg-python. Figured maybe I could figure out how to do what I'm looking for in there, then just extract the ffmpeg command it uses. Otherwise, it looks like it might take me a while to dig through some documentation (which I'm planning on doing) to find something useful.
While I do that, any other recommendations? Has anybody else tried to do something similar to this? Is ffmpeg the best option?
I don't think this is a very unique situation. Seems like something that has been done before.