1

I have working code to create video slideshow from images with some fade-in, fade-out effects:

ffmpeg -video_size 1280x720 \
-loop 1 -t 2.5 -i ok/image-1.jpg \
-loop 1 -t 2.5 -i ok/image-2.jpg \
-loop 1 -t 2.5 -i ok/image-3.jpg \
-loop 1 -t 2.5 -i ok/image-4.jpg \
-loop 1 -t 2.5 -i ok/image-5.jpg \
-filter_complex \
"[0:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[pre]; \
 [0:v]drawtext=enable='between(t,0,5)':fontfile=/Library/Fonts/Arial.ttf:text='FIRST TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th[top0]; \
 [1:v][0:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b1v]; \
 [1:v]drawtext='between(t,5,10)':fontfile=/Library/Fonts/Arial.ttf:text='SECOND TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th[top1]; \
 [2:v][1:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b2v]; \
 [2:v]drawtext='between(t,10,15)':fontfile=/Library/Fonts/Arial.ttf:text='THIRD TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th[top2]; \
 [3:v][2:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b3v]; \
 [3:v]drawtext='between(t,15,20)':fontfile=/Library/Fonts/Arial.ttf:text='FOURTH TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th[top3]; \
 [4:v][3:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b4v]; \
 [4:v]drawtext='between(t,20,25)':fontfile=/Library/Fonts/Arial.ttf:text='FIFTH TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th[top4]; \
[pre][top0][0:v][b1v][top1][1:v][b2v][top2][2:v][b3v][top3][3:v][b4v][top4][4:v]concat=n=15:v=1:a=0,format=yuv420p[v]" -map "[v]" out.mp4

How can i make "FIRST TEXT" to display together with first slide "ok/image-1.jpg" for all 5 seconds? Now it's shows only for around 2 seconds and hides. Also is there possibility to show multiple texts for first slide "ok/image-1.jpg"?

enable='between(t,0,5) is not working for all 5 seconds.

1 Answer 1

1

Try

ffmpeg \
-loop 1 -t 6 -i ok/image-1.jpg \
-loop 1 -t 5 -i ok/image-2.jpg \
-loop 1 -t 5 -i ok/image-3.jpg \
-loop 1 -t 5 -i ok/image-4.jpg \
-loop 1 -t 5 -i ok/image-5.jpg \
-filter_complex \
"[0:v]drawtext=fontfile=/Library/Fonts/Arial.ttf:text='FIRST TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th,drawtext=fontfile=/Library/Fonts/Arial.ttf:text='AFTER FIRST TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th+100,split[pre][pbv0];[pbv0]fifo[bv0]; \
 [pre]fade=t=in:st=0:d=1[v0]; \
 [1:v]drawtext=fontfile=/Library/Fonts/Arial.ttf:text='SECOND TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th,split=3[pbv1a][pbv1b][v1];[pbv1a]fifo[bv1a];[pbv1b]fifo[bv1b]; \
 [2:v]drawtext=fontfile=/Library/Fonts/Arial.ttf:text='THIRD TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th,split=3[pbv2a][pbv2b][v2];[pbv2a]fifo[bv2a];[pbv2b]fifo[bv2b];\
 [3:v]drawtext=fontfile=/Library/Fonts/Arial.ttf:text='FOURTH TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th,split=3[pbv3a][pbv3b][v3];[pbv3a]fifo[bv3a];[pbv3b]fifo[bv3b]; \
 [4:v]drawtext=fontfile=/Library/Fonts/Arial.ttf:text='FIFTH TEXT':fontcolor=white:fontsize=24:x=(w-tw)/2:y=(h/PHI)+th,split[pbv4][v4];[pbv4]fifo[bv4]; \
 [bv1a][bv0]blend=all_expr='A*T/0.5+B*(0.5-T)/0.5',trim=0:0.5[01v]; \
 [bv2a][bv1b]blend=all_expr='A*T/0.5+B*(0.5-T)/0.5',trim=0:0.5[12v]; \
 [bv3a][bv2b]blend=all_expr='A*T/0.5+B*(0.5-T)/0.5',trim=0:0.5[23v]; \
 [bv4][bv3b]blend=all_expr='A*T/0.5+B*(0.5-T)/0.5',trim=0:0.5[34v]; \
 [v0][01v][v1][12v][v2][23v][v3][34v][v4]concat=n=9,format=yuv420p[v]" -map "[v]" out.mp4

I've assumed that you want the text to be present during the cross-fade. So, I've retooled your command. All drawtexts should be applied first and those outputs should be blended.

4
  • Thank you for your help, but "SECOND TEXT" and "FOURTH TEXT" shows only for 1 second, but i need 5 seconds. Here is my console output - link
    – kostya572
    Commented Dec 30, 2016 at 14:07
  • Thank you, everything works, you helped me a lot. I've spent near one day to solve this problem and it was unsuccessful. Please edit this code near "[pbv4]fifo[bv4]" with a semicolon, i can't edit one character at SU. I'm sorry, but if it's not a hard question: how to make these "FIRST TEXT" appear with some fade-in effect at the 2nd second and it dissapear with fade-out effect at the 4th second?
    – kostya572
    Commented Dec 30, 2016 at 21:24
  • Replace fonotcolor with fontcolor_expr='ffffff%{eif:clip(255*(1*between(t,$S+$FI,$E-$FO)+((t-$S)/$FI)*between(t,$S,$S+$FI)+(-(t-$E)/$FO)*between(t,$E-$FO,$E)),0,255):x:2}' where S = start time, E = end time, FI is fade in duration and FO is fade out duration.
    – Gyan
    Commented Dec 31, 2016 at 4:51
  • how can i calculate time for the crawling text right to left by drawtext in ffmpeg.? ` ffmpeg -f lavfi -i "color=color=0xff0000, scale=640x340, drawtext=enable='gte(t,0)':text='firstText, banana, grapes, mango, watermelon, orange, apple, cucumber, lastText':expansion=normal:fontfile=verdana.ttf: y=h-line_h-120:x=-100*t:fontcolor=0x0000ff: fontsize=60: r=10/1" -t 20 OutPut.mp4` I want to make duration of video when my all text scrawled completely
    – manish1706
    Commented Jul 4, 2017 at 10:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .