0

I have a sequence of images which I would like to display to some music that plays at 130bpm. I'll also need to scale down the images, which are a rather strange 2673x2151 pixels, to something that would fit inside a 1080p frame -- e.g. 1342x1080.

130BPM yields weirdness with the most common frame rates. There are 2.16666666667 (13/6) beats per second. This being the case, there doesn't seem to be an integer (i.e., non-fractional) number of frames to show each each image at the usual frame rates (24, 25, 30 fps). If I can make a movie with a frame rate of 2.16666667 frames per second, i could simply show each image for one frame. This seems like it might actually be optimal -- it would probably make a a very compact video file, right?? Question 1: can one specify fractional frame rates?

Alternatively, if we must set the frame rate to an positive integer value, 13 frames per second works if we just display each image for six frames. 13 FPS means 780 frames per minute. 780 frames divided by 130 beats means 6 frames per beat.

Finally, my images are named j1.jpg, j2.jpg, j3.jpg, etc.

Question 2: Can someone help me concoct an ffmpeg command to assemble these images, first in order, then reversed, into a video with each image lasting one beat at 130BPM? I'd like some common video format like MP4 or h264/265, something I can post to social media.

I've been trying to massage this command, which does assemble the images into a movie, but my attempts to specify a frame rate have had weird effects. E.g., doing a -r results in strange videos that change image very erratically. I think it's because there's a setpts=N/25/TB bit in there.

ffmpeg -pattern_type glob -i "j*.jpg" -filter_complex "[0]reverse[r];[0][r]concat,loop=2:250,setpts=N/25/TB,scale=1342:1080" -pix_fmt yuv420p -c:v libx264 -preset slow -b:v 3500k output_looped.mp4

Question 3: how does one specify a number of frames to repeat each image? The default is one frame per image. If we want to specify more than one frame per image, how?

Question 4: What does setpts=N/25/TB specify? I've read the docs on setpts but it's not clear to me what the three values are specifying without the option names.

Question 5: What does the 250 mean in loop=2:250? The docs on loop also don't explain what values are set when you don't supply the specific option names.

1 Answer 1

0

You can specify fractional frame rates.

Use

ffmpeg -pattern_type glob -framerate 130/60 -i "j*.jpg" -filter_complex "[0]scale=1342:1080,setpts=1*PTS,split=2[f][r];[r]reverse[r];[f][r]concat" -pix_fmt yuv420p -fps_mode cfr -c:v libx264 -preset slow -b:v 3500k output_looped.mp4

Change the coefficient in setpts to set frame repeat value.

P.S. option values without option names are treated as corresponding to order of option declaration, e.g. in loop=2:250 2 is value for option loop, and 250 for size. In setpts, N/25/TB is an expression and means to retime frames to be 25 fps.

2
  • Thank you for this answer. I have tried your command, but encounter an error: Unrecognized option 'fps_mode'. Error splitting the argument list: Option not found
    – S. Imp
    Commented Sep 14, 2023 at 17:43
  • You need ffmpeg ver 6.0 or lewer.
    – Gyan
    Commented Sep 15, 2023 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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