user19307: I want to add timestamp of current played time to a video, so I use this:
ffmpeg -i video.mkv -filter_complex "drawtext=fontfile=/Library/Fonts/Arial.ttf: 
       text='timestamp: %{pts \: hms}': x=5: y=5: fontsize=16:
       fontcolor=yellow@0.9: box=1: boxcolor=blue@0.6" -c:a copy -c:v libx264 -map 0 output.mkv

This comes out that the timestamp was in hh:mm:ss:mm format, but I want it in hh:mm:ss format. So how can I achieve this goal?

user1871: Use
text='timestamp \: %{pts\:gmtime\:0\:%H\\\:%M\\\:%S}'


user20276: Do
In order to draw Timestamp: 01:25., you should specify this one to (feed) ffmpeg:
drawtext = text = 'Timestamp\: %{pts\:gmtime\:0\:%M\\\:%S}.'

Don't
If you specify this one to (feed) ffmpeg:
drawtext = text = '%{pts\:gmtime\:0\:%M\\:%S}'

, it gives Unterminated %{} near '{pts:gmtime:0:%M\' error.
But in bash
But if you're using bash-like shell and a weak quote, "......", to feed it,

\\ is escaped to \, and
\: is not escaped but remains without any changes because \: is not an escape sequence.

So it should be:
-filter_complex "drawtext = text = '%{pts\:gmtime\:0\:%M\\\\\:%S}'"

i.e. bash's "\\\\\:" for ffmpeg's \\\: for getting a single character : displayed.
Note that
If you only want to apply one or more filters to one video stream (e.g, drawtext), you can use -vf instead of using --filter_complex. The latter is reserved for applying filters on multiple streams.

19307: <p>I want to add timestamp of current played time to a video, so I use this:</p>

<pre><code>ffmpeg -i video.mkv -filter_complex "drawtext=fontfile=/Library/Fonts/Arial.ttf: 
       text='timestamp: %{pts \: hms}': x=5: y=5: fontsize=16:
       fontcolor=yellow@0.9: box=1: boxcolor=blue@0.6" -c:a copy -c:v libx264 -map 0 output.mkv
</code></pre>

<p>This comes out that the timestamp was in hh:mm:ss:mm format, but I want it in hh:mm:ss format. So how can I achieve this goal?</p>
 1871: <p>Use</p>

<pre><code>text='timestamp \: %{pts\:gmtime\:0\:%H\\\:%M\\\:%S}'
</code></pre>
 20276: <h2>Do</h2>

<p>In order to draw <code>Timestamp: 01:25.</code>, you should specify this one to (feed) <code>ffmpeg</code>:</p>

<pre><code>drawtext = text = 'Timestamp\: %{pts\:gmtime\:0\:%M\\\:%S}.'
</code></pre>

<h2>Don't</h2>

<p>If you specify this one to (feed) <code>ffmpeg</code>:</p>

<pre><code>drawtext = text = '%{pts\:gmtime\:0\:%M\\:%S}'
</code></pre>

<p>, it gives <code>Unterminated %{} near '{pts:gmtime:0:%M\'</code> error.</p>

<h2>But in <code>bash</code></h2>

<p>But if you're using <code>bash</code>-like shell and a weak quote, <code>"......"</code>, to feed it,</p>

<ol>
<li><p><code>\\</code> is escaped to <code>\</code>, and</p></li>
<li><p><code>\:</code> is not escaped but remains without any changes because <code>\:</code> is not an escape sequence.</p></li>
</ol>

<p>So it should be:</p>

<pre><code>-filter_complex "drawtext = text = '%{pts\:gmtime\:0\:%M\\\\\:%S}'"
</code></pre>

<p>i.e. <code>bash</code>'s <code>"\\\\\:"</code> for <code>ffmpeg</code>'s <code>\\\:</code> for getting a single character <code>:</code> displayed.</p>

<h2>Note that</h2>

<p>If you only want to apply one or more filters to one video stream (e.g, <code>drawtext</code>), you can use <code>-vf</code> instead of using <code>--filter_complex</code>. The latter is reserved for applying filters on multiple streams.</p>
