I want to merge 5 images with transition at specific times 4.00, 10.0, 16.0, 22.0, with a transition duration of 1 sec, and a 27 sec audio into a 27 sec video clip.
I used the below command, and got output video of 10 min 43 sec
./ffmpeg
-i 27.m4a
-loop 1 -t 4.0 -i image01.jpeg
-loop 1 -t 6.0 -i image02.jpeg
-loop 1 -t 6.0 -i image03.jpeg
-loop 1 -t 6.0 -i image04.jpeg
-loop 1 -t 5.0 -i image05.jpeg
-movflags faststart -pix_fmt yuva420p
-filter_complex "
[1:v] format=pix_fmts=yuva420p,
scale=1080:1920:force_original_aspect_ratio=decrease,
pad=1080:1920:(ow-iw)/2:(oh-ih)/2,
zoompan=z='if(eq(on,1),1,zoom+0.0004170)':x='iw-iw/zoom':y='0':fps=60:d=60*4.000:s=1080x1920,
crop=w=1080:h=1920:x='(iw-ow)/2':y='(ih-oh)/2',
setpts=PTS-STARTPTS+0.000/TB[v0];
[2:v] format=pix_fmts=yuva420p,
scale=1080:1920:force_original_aspect_ratio=decrease,
pad=1080:1920:(ow-iw)/2:(oh-ih)/2,
zoompan=z='if(eq(on,1),1,zoom+0.0004170)':x='0':y='ih-ih/zoom':fps=60:d=60*6.000:s=1080x1920,
crop=w=1080:h=1920:x='(iw-ow)/2':y='(ih-oh)/2',
setpts=PTS-STARTPTS+4.000/TB[v1];
[3:v] format=pix_fmts=yuva420p,
scale=1080:1920:force_original_aspect_ratio=decrease,
pad=1080:1920:(ow-iw)/2:(oh-ih)/2,
zoompan=z='if(eq(on,1),1,zoom+0.0004170)':x='0':y='ih-ih/zoom':fps=60:d=60*6.000:s=1080x1920,
crop=w=1080:h=1920:x='(iw-ow)/2':y='(ih-oh)/2',
setpts=PTS-STARTPTS+10.000/TB[v2];
[4:v] format=pix_fmts=yuva420p,
scale=1080:1920:force_original_aspect_ratio=decrease,
pad=1080:1920:(ow-iw)/2:(oh-ih)/2,
zoompan=z='if(eq(on,1),1,zoom+0.0004170)':x='iw-iw/zoom':y='0':fps=60:d=60*6.000:s=1080x1920,
crop=w=1080:h=1920:x='(iw-ow)/2':y='(ih-oh)/2',
setpts=PTS-STARTPTS+16.000/TB[v3];
[5:v] format=pix_fmts=yuva420p,
scale=1080:1920:force_original_aspect_ratio=decrease,
pad=1080:1920:(ow-iw)/2:(oh-ih)/2,
zoompan=z='if(eq(on,1),1,zoom+0.0004170)':x='iw-iw/zoom':y='ih-ih/zoom':fps=60:d=60*5.000:s=1080x1920,
crop=w=1080:h=1920:x='(iw-ow)/2':y='(ih-oh)/2',
setpts=PTS-STARTPTS+22.000/TB[v4];
[v0][v1]xfade=transition=circlecrop:duration=1.00:offset=3.000[v01];
[v01][v2]xfade=transition=hrslice:duration=1.00:offset=8.000[v12];
[v12][v3]xfade=transition=slideleft:duration=1.00:offset=13.000[v23];
[v23][v4]xfade=transition=vdslice:duration=1.00:offset=18.000[v34]"
-map "0:a" -map [v34] -y output.mp4
====
I think I need to tweak the time values are specified at 4 places to get this right
-loop 1 -t TIMESTAMP1
I set this to expected duration of each image i.e, 4, 6, 6, 6, 5
zoompan=z='if(eq(on,1),1,zoom+0.0004170)':x='iw-iw/zoom':y='0':fps=60:d=60* TIMESTAMP2 :s=1080x1920,
I set this to expected duration of each image i.e, 4, 6, 6, 6, 5
setpts = PTS - STARTPTS+ TIMESTAMP3 /TB
I set this to cumulative offset from 0 i.e, 0, 4, 10, 16, 22
Additionally, I ensured that
TIMESTAMP2 + TIMESTAMP3 = time at which each image display should end ie., 4, 10, 16, 22, 27
xfade=transition=circlecrop:duration=1.00:offset=TIMESTAMP4
=======
Few problems
- The transition between images, is not as per the times i expect
- Overall clip length is long 10:43 as opposed to expected 00:27
- Overall processing time is 5+ minutes
Am i missing something ?
question from:
https://stackoverflow.com/questions/65867640/ffmpeg-combine-multiple-images-output-video-incorrect-xfade-transition-time-a