[FFmpeg-user] Drawtext with PTS and creation time

Nathan Beach nathan at nathanbeach.com
Sat Dec 12 10:52:20 CET 2015


Hi Tanglor again,

I finally figured out a hackish way to do this with a script, using
ffprobe.  I'm not really a shell programmer, so forgive me if something
here is really dumb.  I've just pieced it together from dozens of
stackoverflow posts, and it works to overlay a formatted creation_date in
the bottom right corner of the video between seconds 2 and 7.

The creation_date in my files seemed to be GMT, so I had to convert them to
CDT as well... maybe this will help you.  This works on Mac OSX 10.10.5,
and you might have to tweak some stuff on other platforms:

#!/bin/bash

for CURRENT_FILE in *.mov; do
    CREATION_TIME=`ffprobe -v quiet "$CURRENT_FILE" -print_format compact
-show_entries format_tags=creation_time`

    # in the format like: "format|tag:creation_time=2015-12-08 16:13:13"
    CDATE=${CREATION_TIME:(25)}

    SECONDS=`TZ="Europe/London" date -j -f "%Y-%m-%d %T" "$CDATE" +%s`
    MY_TIME=`TZ="America/Chicago" date -r $SECONDS +"%Y-%m-%d %I:%M %p"`

    ffmpeg -i "$CURRENT_FILE" -vf
"drawtext=enable='between(t,2,7)':fontfile=/Library/Fonts/Microsoft/Arial.ttf:fontcolor=white:fontsize=64:text=\'${MY_TIME}\':x=main_w-(text_w+64):y=main_h-(text_h*2)"
-acodec copy -y "../output/$CURRENT_FILE"

done

I finally got this to work, but I try to assemble the videos using concat
and the audio is off and the video plays back too slowly.  I've been
messing with this all day, and I pretty much give up.  Video processing is
just too hard for my cro-magnon brain.

NBB


More information about the ffmpeg-user mailing list