There is no builtin option for drawing resolution bitrate and frame rate, so we have to define an environment variable, and pass it to FFmpeg.
Formatting a string in Windows shell, is messy and the following "single line" example is far from perfect:
for /f "tokens=1" %i in ('ffprobe "-v" "error" "-select_streams" "v:0" "-show_entries" "stream=width,height" "-of" "csv=s=x:p=0" "input.mp4"') do set "resolution=%i" && for /f "tokens=1" %i in ('ffprobe "-v" "error" "-select_streams" "v:0" "-show_entries" "stream=bit_rate" "-of" "csv=p=0" "input.mp4"') do set "bitrate=%i" && for /f "tokens=1" %i in ('ffprobe "-v" "error" "-select_streams" "v:0" "-show_entries" "stream=r_frame_rate" "-of" "csv=p=0" "input.mp4"') do set "framerate=%i" && set str='%resolution% / %bitrate% bps / %framerate% fps' && ffmpeg -y -i input.mp4 -vf "drawtext=fontfile=C\\:/Windows/fonts/consola.ttf:text='%str%':x=(w-tw)/2:y=h-(2\*lh):fontcolor=black:fontsize=50:box=1: boxcolor=white:boxborderw=5" -c:a copy output.mp4
- Use FFprobe, for getting the resolution, bitrate and frame rate (I didn't try to convert the bitrate from bps to kbps).
Adding -pretty
argument format the rate to 1.672451 Mbit/s
.
- Assign the output of FFmpeg to variables as described here (all the solutions are not very elegant).
set str='%resolution% / %bitrate% bps / %framerate% fps'
- formats the final string to the environment variable str
.
text='%str%'
draws the content of variable str
.
&&
is used for concatenating the 4 commands into single line.
Note: FFprobe is executed 3 times, because it looks like there is no option to add custom text between elements (we better look for more elegant solution).
Removing the /
from the 60/1
is possible using shell string manipulation as described here: set frate=%framerate:~0,-2%
.
Use drawtext
filter twice (separated by comma) for drawing two text boxes.
--
Output example:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/JKHyu.png)
Note:
The solution would be much more elegant using scripting language like Python, instead of Windows console.