1

I'm trying to create a video from a set of images, adding texts to each image that slide from one side to the center ( one left to right, another right to left ), with fading between each videos ( not between text but between video ).

Actually I have this code that generare a simple video, with text sliding and fade:

ffmpeg -y \
    -loop 1 -t 10 -i img001.jpg  \
    -loop 1 -t 10 -i img002.jpg  \
-filter_complex \
"\
[0:v]\
drawtext=fontfile='IndieFlower.ttf':enable='between(t,0,5)':\
text='Caption 1 Scena 1':\
fontsize=60:fontcolor=white:\
x=t*300*lte(t*300\,(w-text_w)/2)+(w-text_w)/2*gt(t*300\,(w-text_w)/2):y=h-line_h-10:\
shadowx=3:shadowy=3:shadowcolor=black:\
boxborderw=10:box=1:boxcolor=red@0.8,\
drawtext=fontfile='IndieFlower.ttf':enable='between(t,5,10)':\
text='Caption 2 Scena 1':\
fontsize=60:fontcolor=white:\
x=(w-(t-5)*500)*gt(w-(t-5)*500\,(w-text_w)/2)+(w-text_w)/2*lte(w-(t-5)*500\,(w-text_w)/2):y=h-line_h-10:\
shadowx=3:shadowy=3:shadowcolor=black:\
boxborderw=10:box=1:boxcolor=red@0.8\
[final1];\
[1:v]\
fade=t=in:st=0:d=1,\
drawtext=fontfile='IndieFlower.ttf':enable='between(t,0,5)':\
text='Caption 1 Scena 2':\
fontsize=60:fontcolor=red:\
x=t*300*lte(t*300\,(w-text_w)/2)+(w-text_w)/2*gt(t*300\,(w-text_w)/2):y=h-line_h-10:\
shadowx=3:shadowy=3:shadowcolor=white:\
boxborderw=10:box=1:boxcolor=black@0.8,\
drawtext=fontfile='IndieFlower.ttf':enable='between(t,5,10)':\
text='Caption 2 Scena 2':\
fontsize=60:fontcolor=red:\
x=(w-(t-5)*500)*gt(w-(t-5)*500\,(w-text_w)/2)+(w-text_w)/2*lte(w-(t-5)*500\,(w-text_w)/2):y=h-line_h-10:\
shadowx=3:shadowy=3:shadowcolor=white:\
boxborderw=10:box=1:boxcolor=black@0.8\
[final2];\
[final1][final2]concat[final]
" \
-pix_fmt yuvj422p -t 20 -map '[final]' o.mp4

It works well, but now, I'd like to add a zoompan effect to both of the images; so I change the code as follow:

[0:v]\
format=yuvj422p,
scale=iw*10:ih*10,\
zoompan=z='min(zoom+0.0015,1.5)':d=500:x='iw/2-(iw/zoom/2)':y='ih/2 (ih/zoom/2)':s=640x480,\
drawtext=fontfile='IndieFlower.ttf':enable='between(t,0,5)':\

...

[1:v]\
format=yuvj422p,
scale=iw*10:ih*10, \
zoompan=z='min(zoom+0.0015,1.5)':d=500:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':s=640x480,\
fade=t=in:st=0:d=1,\
...

but this does not work; in the final video there is only the first "video", with the zoompan, the second video does not appear at all!

What I'm doing wrong? I'd like to create a simple zoompan between two video.

3

zoompan is a weirdly designed filter. It operates on individual frames, whereas most filters operate on a sequence of pictures, whether they are fed from a video file or an image sequence. pzoom should be used for a looped image, and frame sequence generation should be stopped by making d=1.

Change to

zoompan=z='min(pzoom+0.0015,1.5)':d=1:x='iw/2-(iw/zoom/2)':y='ih/2 (ih/zoom/2)':s=640x480

This will fix the zoompan.

  • Thanks! It works! Really Thanks! I just have these messages: [swscaler @ 0x7f3d60016880] deprecated pixel format used, make sure you did set range correctly, I'm using -pix_fmt yuvj422p, is not correct? – GFCoder977 Feb 9 '18 at 15:49
  • 1
    For final output, yuv420p is standard. – Gyan Feb 9 '18 at 15:58
  • Thanks, it works. To finish my job, I need to add an mp3 to the process. Should I open a new Ask Question, or you can suggest me how to add this new input to the command above? I tryed adding [final1][final2][2:0]concat=n=2:v=1:a=1[finalVideo][finalAudio] but it does not work ( mp3 is the third input ) – GFCoder977 Feb 9 '18 at 17:36
  • You don't need to add the audio to the concat. Remove the -map [final] – Gyan Feb 9 '18 at 18:14

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.