Answers.Body: <p>Wow... ffmpeg never ceases to amaze.. it's built in!</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The important bit for the timecode being: <code>text='%{gmtime\:%H\\\\\:%M\\\\\:%S}'</code></p>
  
  <p>There is some crazy escaping in there to get the colons to display(in <code>bash</code>), but that is UTC/GMT time of day timecode burnt in... just need to figure out the syntax for multiple <code>drawtext</code> functions now and I'm all set...</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-12-03T23:07:29.600Z
Answers.Text: What is the -re option for?
Answers.UserDisplayName: Ricardo Bohner
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-02T17:26:01.077Z
Answers.LastActivityDate: 2019-01-03T16:47:41.190Z
Answers.LastEditDate: 2019-01-03T16:47:41.190Z
Answers.UserDisplayName: Fat Monk
Body: <p>I'm using the following <code>ffmpeg</code> command to create an H.264 encoded MPEG transport stream from a single png file with a text overlay.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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)</p>
  
  <p>I'm trying to do this on a linux (Ubuntu) platform.</p>
  
Tags: <ffmpeg>
Title: Realtime time overlay with ffmpeg
UserDisplayName: Fat Monk
ThreadText: # Realtime time overlay with ffmpeg
  
  (Asked by: username_0 on 2019-01-02)
  
  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.
  
  **Tags:** ffmpeg
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-01-02. Score: 9 | Accepted answer
  
  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...
  
  > **Comments:**
  > **username_1**: What is the -re option for?  
  
  ---
  
  