Search code examples
node.jsffmpegstreamvideo-streamingfluent-ffmpeg

FFmpeg stream dynamic png


I would like to know if its possible to stream a png or any kind of image using ffmpeg. I would like to generate the image contiously using nodejs that updates every 10 seconds. I would like to display game stats with this in a corner and mix it with some background music or pre recorded commentary on it. Additionaly i would like to mix a video and the image should act like an overlay.

I am also not sure if using a transparent png image its possible to do

I couldn't get my head around doing the mixing with ffmpeg and its looks very complicated so i would like to get some help on it.

I have video files stored in a folder that i would like to continously stream and mix different music and an image on it. I would like to have it all continously working without stopping the stream.

Is it possible with ffmpeg cli on linux or i cant avoid using a desktop windows pc for such thing?


Solution

  • Well after digging through the documentation and asking for help on irc i came up with the following command:

    First i store the list of tracks in a txt file such as: playlist.txt

    file 'song1.mp3'
    file 'song2.mp3'
    file 'song3.mp3'
    

    Then i want to concat the tracks so i use -concat and specify the input as a txt file.

    The second thing is using a static image as an input that i can manually update.

    ffmpeg -re -y -f concat -safe 0 -i playlist.txt -framerate 1 -loop 1 -f image2 \
     -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -r 12 -g 24 -b:v 4500k \
     -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 128k -bufsize 512k \
     -f flv "rtmp://"
    

    The rest is specificing the output format and other settings for streaming.

    Thats what i came up with so far, not sure if theres any better way of doing this but right now it is sufficient enough for my needs.