-
Notifications
You must be signed in to change notification settings - Fork 19
Burn Frame Number
George Stoyanov edited this page May 14, 2019
·
5 revisions
ffmpeg -i <input> \
-vf "drawtext=fontfile=Arial.ttf: text=%{n}: x=(w-tw)/2: y=h-(2*lh): \
fontsize=20: fontcolor=white: box=1: boxcolor=0x00000099" \
-c:v libx264 -b:v 5M \
-c:a aac -ac 2 -b:a 128k <output.mp4>
Please note that when you are using the -vf
video filter option you need always to encode the video.
In this example, the font size is in pixels so I would suggest using different -fontsize
depending on the output resolution. For SD 20 should be fine, for HD, 50 and for UHD 100. The burning of the frame numbers always require re-encoding the video, that's why I am re-encoding the input file to output.mp4
using H264 encoding and 5Mbps for the video stream and 128Kbps and AAC for the audio stream.
ffmpeg -i <input> \
-vf 'scale=1280x720, bwdif=0:-1:0, drawtext=fontfile=Arial.ttf: text=%{n}: x=(w-tw)/2: y=h-(2*lh): \
fontsize=35: fontcolor=white: box=1: boxcolor=0x00000099' \
-c:v libx264 -r 50 -b:v 5M \
-c:a aac -ac 2 -b:a 128k <output.mp4>
The difference here is that we separate the scale
(re-scaling) and bwdif
(de-interlacing) from the drawtext
filter function with commas.