How Can I Show a Timecode While Playing Audio in Ffplay?

I'm wanting to play strictly audio files with FFplay. Already when opening files it displays a window with a rolling spectogram.

I'd like to have the same spectogram with an overlay of a timecode in hh:mm:ss.

There is nothing on the man page whatsoever of this.

How can I achieve this?

1 Answer

This can be done with the showspectrum and drawtext filters.

ffplay -f lavfi "amovie=input.mp3,asplit[a][out1];[a]showspectrum=mode=separate:color=intensity:slide=1,drawtext=text='%{pts\:hms}':box=1:boxborderw=5:x=(w-text_w)/2:y=h-(text_h*2):fontsize=16:font=Mono[out0]"
  • Seeking during playback will not be possible.
  • Use a mono font, otherwise the width of the numbers will vary causing movement. The use of the option font=Mono allows you to set the font family, but this requires your ffmpeg to be compiled with --enable-libfribidi. Otherwise, use the fontfile option and provide the full path to the font file.
0

Your Answer

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

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest