Last active
September 12, 2024 18:44
-
-
Save aniongithub/7c6a346e3531521c37480dd410f9a5e2 to your computer and use it in GitHub Desktop.
Add a timer or other text display to a video using FFMPEG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# From: https://discuss.kde.org/t/date-time-overlay-in-timelapse-video/2880/5 | |
# Monospaced font from here: https://www.1001fonts.com/download/digital-7.zip | |
INPUT_FILE="video.mp4" | |
TOTAL_DURATION=30 # Total duration in seconds | |
FPS=30 | |
FONT_FILENAME="./digital-7/digital-7 (mono).ttf" | |
FONT_SIZE=72 | |
FONT_COLOR="white" | |
OUTPUT_BITRATE=800k | |
ffmpeg -an -y -i ${INPUT_FILE} -vf "drawtext=fontfile=${FONT_FILENAME}: | |
fontsize=${FONT_SIZE}: | |
fontcolor=${FONT_COLOR}: | |
x=w-tw-50: | |
y=h-th-50: | |
text='%{eif\:trunc(n/${FPS}*${TOTAL_DURATION}/(${FPS}*60*60))\:d\:02}\:%{eif\:trunc(mod(n/${FPS}*${TOTAL_DURATION}/(${FPS}*60),60))\:d\:02}\:%{eif\:trunc(mod(n/${FPS}*${TOTAL_DURATION}/${FPS},60))\:d\:02}'" \ | |
-vcodec libx264 \ | |
-b ${OUTPUT_BITRATE} \ | |
-f mp4 output.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment