1

I'm using the following ffmpeg command to create an H.264 encoded MPEG transport stream from a single png file with a text overlay.

ffmpeg -re -loop 1 -i smpte-color-bars-1080p.png -vf drawtext="fontfile=monofonto.ttf: fontsize=96: box=1: boxcolor=black@0.75: boxborderw=5: fontcolor=white: x=(w-text_w)/2: y=(h-text_h)/2: text='MY OVERLAY'" -r 25 -vcodec libx264 -f mpegts udp://0.0.0.0:1234

This seems to be working well, but as it is static you cannot easily tell if the encode has stopped. I'd therefore also like to add a timecode overlay so that the image has some changing content.

It is important that the stream is generated from a single static frame as I want the stream to be absolutely continuous and not a looped pre-encoded TS file.

Is there any way to add this dynamic overlay using ffmpeg? (I'm currently thinking piping one stream into another but that seems a bit hacky)

I'm trying to do this on a linux (Ubuntu) platform.

1

Wow... ffmpeg never ceases to amaze.. it's built in!

ffmpeg -re -loop 1 -i smpte-color-bars-1080p.png -vf drawtext="fontfile=monofonto.ttf: fontsize=96: box=1: boxcolor=black@0.75: boxborderw=5: fontcolor=white: x=(w-text_w)/2: y=((h-text_h)/2)+((h-text_h)/4): text='%{gmtime\:%H\\\\\:%M\\\\\:%S}'" -r 25 -vcodec libx264 -f mpegts udp://127.0.0.1:1234

The important bit for the timecode being: text='%{gmtime\:%H\\\\\:%M\\\\\:%S}'

There is some crazy escaping in there to get the colons to display(in bash), but that is UTC/GMT time of day timecode burnt in... just need to figure out the syntax for multiple drawtext functions now and I'm all set...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.