0

Hi i am trying to add to display the current time of the video as an overlay. i have tried to do follow the answer of this previous post: https://superuser.com/questions/968685/how-to-display-current-time-with-the-ffplay-exe but with no luck.

This is my line of code:

"./ffmpeg-2023-01-25-git-2c3107c3e9-full_build/bin/ffplay.exe" -vf "drawtext=fontfile=./consola.ttf:text='%{pts:hms}':fontsize=48:fontcolor=white:box=1:boxborderw=6:boxcolor=black@0.75:x=(w-text_w)/2:y=h-text_h-20" -i "%shadowplays_folder%\%NEWEST_FOLDER%\%NEWEST_FILE%" -autoexit -x "1000" -alwaysontop

This will display the text "hms}" not the time.

the above code works fine if i replace it with a simple string:

"./ffmpeg-2023-01-25-git-2c3107c3e9-full_build/bin/ffplay.exe" -vf "drawtext=fontfile=./consola.ttf:text='test':fontsize=48:fontcolor=white:box=1:boxborderw=6:boxcolor=black@0.75:x=(w-text_w)/2:y=h-text_h-20" -i "%shadowplays_folder%\%NEWEST_FOLDER%\%NEWEST_FILE%" -autoexit -x "1000" -alwaysontop

This will display the text "test"

what am i missing?

  • 1
    Try `'%%{pts:hms}'` in place of `'%{pts:hms}'` (ten-second test for you, I haven't tried it) – Magoo Jan 28 '23 at 14:52
  • @Magoo doesn't work. I get a "fontconfig error". Thanks though – lalelarsen1 Jan 28 '23 at 14:55
  • The link you posted has `'%{pts\:hms}'`, not `'%{pts:hms}'`. Maybe try that? – SomethingDark Jan 28 '23 at 15:33
  • The result is the same. But it does work with %%! So thanks to you both – lalelarsen1 Jan 28 '23 at 15:38
  • @Magoo can you explain why this work? i will mark it as the correct answer – lalelarsen1 Jan 28 '23 at 15:41
  • It's because `%` is the character in a batch script that tells the interpreter "this is a variable" so if you want to use it for anything other than that, you need to escape it. For some reason, the escape character for `%` is a second `%` rather than the traditional batch escape character `^`. – SomethingDark Jan 28 '23 at 16:15
  • That does explain why it didnt work when i added "^" because i did suspect it was the issue. But how come is this not an issue on the post i linked to? or on any other site that suggest the same solution? – lalelarsen1 Jan 28 '23 at 17:28

1 Answers1

0

Try '%%{pts:hms}' in place of '%{pts:hms}'

% needs to be escaped by another % to be interpreted literally.

Magoo
  • 77,302
  • 8
  • 62
  • 84