Im streaming a live video using FFMPEG to youtube, what i would love to do is draw a text title on the video at various parts of the video such as at the first frame for 20 seconds and then again every 45 seconds there after. So far I have the below code working:

"-vf" ,  "[in]drawtext=fontsize=20:fontfile=/home/streamer/fonts/Timeless.ttf:textfile=/home/streamer/video_title.txt:fontcolor=white:box=1:boxcolor=black@0.8:boxborderw=5:x=W-w+5:y=h-th-50:enable='between(t,0,20)+between(t,45,65)'[out]

It successfully makes the title appear at 0-20 seconds and then again at 45-65 seconds, is there a way to dynamiclly make it come lets say at the exact center of the video and end of the video programatically?

Like take T/2 and calculate the title to appear in the middle for T/2-20 seconds?

  • Not automatically possible. You have to probe input duration (let's call it X) then it will be enable='between(t,0,20)+between(t,X/2-20,X/2)+gte(t,X)' – Gyan Mar 17 '20 at 5:45
  • @gyan thank you , is there no constant/variable in FFMPEG that automatically represents the duration of the current media FFMPEG is handling as input? or do i have to probe it separately lets say in a shell or python script and pass it to FFMPEG – Fight Fire With Fire Mar 17 '20 at 12:01
  • Yes, there is no constant. – Gyan Mar 17 '20 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.