[FFmpeg-user] Use processed filename as draw text after tmix, in one pass?
William C Bonner
wimbonner at gmail.com
Wed Apr 24 21:24:02 EEST 2024
On Sun, Apr 21, 2024 at 12:08 PM Steven Kan <steven at kan.org> wrote:
> > On Mar 6, 2024, at 11:49 AM, Steven Kan <steven at kan.org> wrote:
> >
> > Planning ahead to the successor to my honeycomb time-lapse video from
> 2022, processed using tmix per advice from this group:
> >
> > https://ffmpeg.org//pipermail/ffmpeg-user/2022-April/054742.html
> >
> > https://www.youtube.com/watch?v=2dUGbGcGE2c
> >
> > This time I’m capturing the photos with a dSLR and gphoto on a Raspberry
> Pi, and the dSLR does not burn in a timestamp.
> >
> > This is actually a good thing, because I don’t like how my timestamps
> got tmixed away last time. I’d like to apply them after tmix.
> >
> > I’m saving the photos with the timestamp as the sortable filename, e.g.
> >
> > 2024-03-06-11-40-11.jpg
> >
> > This time I’d like to tmix 50 frames, read the filename of the 50th
> frame, re-arrange the text of the filename to U.S. style, e.g. "03/06/24,
> 11:40:11 AM", and then drawtext it onto the output.
> >
> > Can this be done in one pass? Or would I need to do a first pass to
> create the text fields in some companion files, e.g.
> 2024-03-06-11-40-11.txt, or even multiple passes to do the tmix first and
> then the drawtext? I’d like to avoid multiple passes of video processing to
> avoid generation loss, if possible.
>
> Partial answer to my own question, from here:
>
>
> https://superuser.com/questions/717103/burn-filenames-of-single-images-into-ffmpeg-output-video
>
> So this command works:
>
> ffmpeg -f image2 -export_path_metadata 1 -pattern_type glob -i '*.jpg'
> -vf "drawtext=text='%{metadata\:lavf.image2dec.source_basename\:NA}':
> fontfile=/System/Library/Fonts/Helvetica.ttc:fontcolor=white: fontsize=48:
> x=(w-text_w)*0.01: y=(h-text_h)*0.98" -y CombLapseWithFilenames.mp4
>
> and creates:
>
> https://www.kan.org/download/CombLapseWithFilenames.mp4
>
> But the drawtext is the original filenames, e.g. 2024-04-21-08-20-11.jpg,
> which format I chose in my photo-taking script so that they’d sort properly.
>
> Can I reformat that in U.S.-style, e.g. "04/21/24, 08:20:11” and strip the
> .jpg extension, and do this all in one pass?
>
I'd recommend using the metadata for your timelapse if it's available
instead of the filename. This is what I'm using in my windows project that
calls ffmpeg to create movies from gopro time lapse photos.
drawtext=fontfile=C\\:/Windows/Fonts/consola.ttf:fontcolor=white:fontsize=main_h/16:y=main_h-text_h-50:x=50:text=%{metadata\\:DateTimeOriginal}
Here's a line I use in a linux project (
https://github.com/wcbonner/WimsConstructionCam/blob/main/wimsconstructioncam.cpp#L1059
)
drawtext=font=mono:fontcolor=white:fontsize=main_h/32:y=main_h-text_h-10:x=10:text=%{metadata\\\\:DateTimeOriginal}
More information about the ffmpeg-user
mailing list