1

I'm trying to write a script to use FFMPEG to draw localized timestamps on a video, but I'm not having much luck.

I can confirm I have the locale fr_FR.UTF-8 installed on my system by running the following command: LC_ALL=fr_FR.UTF-8 date

However, the following command produces a 4 second video beginning with the string "Monday 28 November 2022 19:00:47 PST" on both my Mac and an Alpine Linux docker container:

LC_ALL=fr_FR.UTF-8 ffmpeg -hide_banner -f lavfi -i color=size=1024x768:rate=25:color=black -c:v libx264 -c:a aac -filter_complex drawtext=expansion=normal:fontsize=18:fontcolor=white:box=1:boxcolor=black@0.5:text='%{pts\\:localtime\\:1669690847\\:%A %-d %B %Y %X %Z}' -t 4 -y out.mp4

Does anyone know how to make it create strings with non-English text?

1 Answers1

1

from textfile:

#!/bin/bash
### somehow get start time of video
STA="2022-12-31 23:59:57"
DT1=$(LC_ALL=ru_RU.UTF-8 date --date="$STA" +'%A %-d %B %Y')
DT2=$(date --date="$STA" +%s.%N)
echo "${DT1} %{pts:localtime:${DT2}:%X %Z}" > /tmp/dt.txt

ffmpeg -i "input 1.mp4" -vf "
drawtext=
expansion=normal:
fontsize=h/15:
fontcolor=white:
box=1:
boxcolor=black@0.5:
textfile=/tmp/dt.txt:
x=(w-text_w)/2:
y=(h-text_h*2)
" output.mp4 -y

trim to 2 parts:

#!/bin/bash
### somehow get start time from video
STA="2022-12-31 23:59:57"
DT1=$(LC_ALL=ru_RU.UTF-8 date --date="$STA" +'%A %-d %B %Y')
DT2=$(date --date="$STA" +%s.%N)
echo "${DT1} %{pts:localtime:${DT2}:%X %Z}" > /tmp/dt1.txt
STA="2023-01-01 00:00:00"
DT1=$(LC_ALL=ru_RU.UTF-8 date --date="$STA" +'%A %-d %B %Y')
DT2=$(date --date="$STA" +%s.%N)
echo "${DT1} %{pts:localtime:${DT2}:%X %Z}" > /tmp/dt2.txt

ffmpeg -i "input 1.mp4" -filter_complex "
[0:v]trim=duration=3,
drawtext=
expansion=normal:
fontsize=h/15:
fontcolor=white:
box=1:
boxcolor=black@0.5:
textfile=/tmp/dt1.txt:
x=(w-tw)/2:
y=(h-th*2)[v1];
[0:v]trim=start=3,setpts=PTS-STARTPTS,
drawtext=
expansion=normal:
fontsize=h/15:
fontcolor=white:
box=1:
boxcolor=black@0.5:
textfile=/tmp/dt2.txt:
x=(w-tw)/2:
y=(h-th*2)[v2];
[v1][v2]concat=n=2:v=1:a=0
" out.mp4 -y