1

I'm trying to create a 1920x1080 slideshow from images in a folder using a batch file and ffmpeg. The batch file references a txt file containing the list of files to be concatenated. The images have varying dimensions and need to be up- or downscaled. All images get concatenated and properly resized when using:

-r .2 -f concat -safe 0 -i concat_image_list_JPG.txt -c:v libx264 -crf 22 -pix_fmt yuv420p -vf scale=1920:1080 -r 25 -f mp4 "Slideshow 1080.mkv" -y

but I'd like to add crossfades between them. For some reason, only the first two images are concatenated when using this command:

-r .2 -f concat -safe 0 -i concat_image_list_JPG.txt -c:v libx264 -crf 22 -pix_fmt yuv420p -vf zoompan=d=(4+2)/2:s=1920x1080:fps=1/2,framerate=25:interp_start=0:interp_end=255:scene=100 -r 25 -f mp4 "Slideshow 1080.mkv" -y

What's wrong with the crossfade command? How can I get crossfades and resizing into a single command?

1 Answer 1

0

Add -reinit_filter 0 flag.

According to the following post:

The issue is that the pixel format within each input changes mid-way. This causes the filtergraph to reinitialize and buffered frames get dropped.
Suppress reinitialization and convert to a command pixel format before blending.

It is not necessarily the pixel format change (image size maybe?)

ffmpeg -reinit_filter 0 -r .2 -f concat -safe 0 -i concat_image_list_JPG.txt -c:v libx264 -crf 22 -pix_fmt yuv420p -vf zoompan=d=(4+2)/2:s=1920x1080:fps=1/2,framerate=25:interp_start=0:interp_end=255:scene=100 -r 25 "Slideshow 1080.mkv" -y
11
  • This now works well for the crossfading: -reinit_filter 0 -r .2 -f concat -safe 0 -i concat_image_list_JPG.txt -c:v libx264 -crf 22 -pix_fmt yuv420p -vf zoompan=d=(4+2)/2:s=1920x1080:fps=1/2,framerate=25:interp_start=0:interp_end=255:scene=100 -r 25 -f mp4 "Slideshow 1080.mkv" -y but in the meantime I figured out how to more elegantly scale images of diffrent aspect ratios and came up with this video filter command: -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1:color=black". How can I merge this command into the other video filter command?
    – Sonic
    Jan 16, 2022 at 23:36
  • Try: ffmpeg -reinit_filter 0 -r .2 -f concat -safe 0 -i concat_image_list_JPG.txt -c:v libx264 -crf 22 -pix_fmt yuv420p -vf "scale=1920:1080,setsar=1:1,scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1:color=black,framerate=25:interp_start=0:interp_end=255:scene=100" -r 25 "Slideshow 1080.mkv" -y
    – Rotem
    Jan 17, 2022 at 6:33
  • Why are you using -f mp4 for MKV file?
    – Rotem
    Jan 17, 2022 at 6:34
  • It got copied from someone elses solution for some other issue I had. Should I remove it? I put all my commands together by trial and error and copying other people's commands. Your new solution does create a slideshow, however, I can't figure out how to parametrize the crossfades which are initiated too fast. I'd prefer them like with the former solution but set to zoompan=d=(6+2)/2. Also, images do not keep their aspect ratio as expected with your new solution. The solution in my first comment works well for crossfades and the second vf command for scaling and AR. Can they be combined?
    – Sonic
    Jan 17, 2022 at 9:19
  • Regarding -f mp4, remove it, since the output is MP4 container with .mkv extension. Regarding the aspect ration, you may try removing setsar=1:1. I can't see your issue since I don't have your input images. Regarding parametrizing the crossfades, I don't know the answer (I never used crossfades, I just used the filters from your question). You may post a new question regarding crossfades specifically.
    – Rotem
    Jan 17, 2022 at 11:51

You must log in to answer this question.

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