[FFmpeg-user] Use processed filename as draw text after tmix, in one pass?

Steven Kan steven at kan.org
Thu Apr 25 23:33:51 EEST 2024


> On Apr 24, 2024, at 11:54 PM, Paul B Mahol <onemda at gmail.com> wrote:
> 
> On Thu, Apr 25, 2024 at 6:21 AM Steven Kan <steven at kan.org> wrote:
> 
>> 
>>> Thanks! This works, and I agree that it’s better than using the filename:
>>> 
>>> ffmpeg -pattern_type glob -i '*.jpg' -vf
>> "drawtext=text='%{metadata\\:DateTimeOriginal}':
>> fontfile=/System/Library/Fonts/Helvetica.ttc:fontcolor=white: fontsize=48:
>> x=(w-text_w)*0.01: y=(h-text_h)*0.98" -y CombLapseWithTimeStamp.mp4
>>> 
>>> I can now add tmix after drawtext:
>>> 
>>> ffmpeg -pattern_type glob -i '*.jpg' -vf
>> "drawtext=text='%{metadata\\:DateTimeOriginal}':
>> fontfile=/System/Library/Fonts/Helvetica.ttc:fontcolor=white: fontsize=48:
>> x=(w-text_w)*0.01: y=(h-text_h)*0.98, tmix=frames=10:weights='1'" -y
>> CombLapseWithTimeStampAndTmix.mp4
>>> 
>>> And it renders, but the timestamps get blended.
>>> 
>>> Can I use “split” to make one stream of images from which I can extract
>> the timestamp, and then another stream for tmix, and then overlay the
>> timestamp after tmix? How would I sync up the two streams, since tmix would
>> be N frames shorter than the original?
>> 
>> Hmmm.
>> 
>> This:
>> 
>> https://youtu.be/-NB1JzR5aCQ
>> 
>> is the result of:
>> 
>> ffmpeg -pattern_type glob -i '*.jpg' -vf "split [tmp][main]; [tmp]
>> crop=iw:ih*0.05:0:ih*0.95, drawtext=text='%{metadata\\:DateTimeOriginal}':
>> fontfile=/System/Library/Fonts/Helvetica.ttc:fontcolor=white: fontsize=72:
>> x=(w-text_w)*0.01: y=(h-text_h)*0.01 [text]; [main]
>> tmix=frames=10:weights='1' [blend]; [blend][text] overlay=0:H*0.95" -y
>> CombLapseWithTimeStampAndTmixSplit.mp4
>> 
>> which approximates the result I'm trying to achieve, but it's cheating,
>> because it's making a separate stream of the bottom 5% of the video with
>> the drawtext overlay, and then overlaying that on top of the blended
>> frames. It appears to work only because there's nothing much happening in
>> the bottom half of the frames.  If there were any significant bee activity
>> in the bottom 5% it would be apparent that that section is not getting
>> tmixed.
>> 
>> Can anyone help me construct a filter chain that will overlay the internal
>> timestamp in an arbitrary position on top of the blended frames, after tmix
>> has been applied?
>> 
> 
> Not anyone, but what about adding drawtext *after* tmix ?

I actually tried that first, e.g.:

ffmpeg -pattern_type glob -i '*.jpg' -vf "tmix=frames=10:weights='1', drawtext=text='%{metadata\\:DateTimeOriginal}': fontfile=/System/Library/Fonts/Helvetica.ttc:fontcolor=white: fontsize=48: x=(w-text_w)*0.01: y=(h-text_h)*0.98" -y CombLapseWithTimeStampAndTmix.mp4

and it renders no drawtext. If I change '%{metadata\\:DateTimeOriginal}' to '%{metadata\:lavf.image2dec.source_basename\:NA}' then the drawtext renders as “NA”, presumably because the tmixed images no longer have a filename or a timestamp.



More information about the ffmpeg-user mailing list