<p>You can specify fractional frame rates.</p>
<p>Use</p>
<p><code>ffmpeg -pattern_type glob -framerate 130/60 -i &quot;j*.jpg&quot; -filter_complex &quot;[0]scale=1342:1080,setpts=1*PTS,split=2[f][r];[r]reverse[r];[f][r]concat&quot; -pix_fmt yuv420p -fps_mode cfr -c:v libx264 -preset slow -b:v 3500k output_looped.mp4</code></p>
<p>Change the coefficient in <code>setpts</code> to set frame repeat value.</p>
<p>P.S. option values without option names are treated as corresponding to order of option declaration, e.g. in <code>loop=2:250</code> <code>2</code> is value for option <code>loop</code>, and <code>250</code> for <code>size</code>. In setpts, <code>N/25/TB</code> is an expression and means to retime frames to be 25 fps.</p>

CC BY-SA 4.0
2023-09-14T17:43:55.930Z
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
CC BY-SA 4.0
2023-09-15T04:25:54.617Z
You need ffmpeg ver 6.0 or lewer.
Gyan
CC BY-SA 4.0
2023-08-19T04:07:27.670Z
2023-08-19T04:07:27.670Z
Gyan
<p>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.</p>
<p>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?? <strong>Question 1: can one specify fractional frame rates?</strong></p>
<p>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.</p>
<p>Finally, my images are named j1.jpg, j2.jpg, j3.jpg, etc.</p>
<p><strong>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?</strong> I'd like some common video format like MP4 or h264/265, something I can post to social media.</p>
<p>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 <code>setpts=N/25/TB</code> bit in there.</p>
<pre><code>ffmpeg -pattern_type glob -i &quot;j*.jpg&quot; -filter_complex &quot;[0]reverse[r];[0][r]concat,loop=2:250,setpts=N/25/TB,scale=1342:1080&quot; -pix_fmt yuv420p -c:v libx264 -preset slow -b:v 3500k output_looped.mp4
</code></pre>
<p><strong>Question 3: how does one specify a number of frames to repeat each image?</strong> The default is one frame per image. If we want to specify more than one frame per image, how?</p>
<p><strong>Question 4: What does <code>setpts=N/25/TB</code> specify?</strong> I've read the <a href="https://ffmpeg.org/ffmpeg-filters.html#setpts_002c-asetpts" rel="nofollow noreferrer">docs on setpts</a> but it's not clear to me what the three values are specifying without the option names.</p>
<p><strong>Question 5: What does the 250 mean in <code>loop=2:250</code>?</strong> The <a href="https://ffmpeg.org/ffmpeg-filters.html#loop" rel="nofollow noreferrer">docs on loop</a> also don't explain what values are set when you don't supply the specific option names.</p>

<ffmpeg>
ffmpeg command to scale, show images at exactly 130bpm
S. Imp
# ffmpeg command to scale, show images at exactly 130bpm

(Asked by: username_0 on 2023-08-18)

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.

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2023-08-19. Score: 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.

> **Comments:**
> **username_0**: 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`  
> **username_1**: You need ffmpeg ver 6.0 or lewer.  

---

