<p>I <em>believe</em> you cannot cut less than a frame dealing with video streams.</p>
<p>With 30 fps a single frame is 0.033(3) seconds.
The closest value for your requested 0.238 is 0.233(3). But it is less than needed and to not miss any data ffmpeg takes one more frame which results in 0.266(6). When rounded it is exactly 0.27.</p>

CC BY-SA 4.0
2021-11-05T22:30:48.050Z
2021-11-05T22:30:48.050Z
trainplesky
<blockquote>
<p>Is this something that is limited by the video frame rate?</p>
</blockquote>
<p>Indirectly — if the input video stream has a fixed frame rate. The true reason is system of PTS.</p>
<p>Every frame has its so-called <em>presentation time stamp</em> (PTS), expressed as an <em>integer number</em>.</p>
<p>Your input video stream has probably these PTS:
<a href="https://i.sstatic.net/bqtKm.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/bqtKm.jpg" alt="enter image description here" /></a>
What is the meaning of these integer numbers?</p>
<p>They are multiples of the <em>unit time</em> (a tick) for the stream.</p>
<ul>
<li>In your case, the unit time is as small as <code>1/15360</code> of second, because it is a <em>reciprocal value</em> of the so-called <em>time base</em>, and the time base for your input stream is 15360<br />
(see <code>..., 15360 tbn, ...</code> in your listing).</li>
</ul>
<p>Here are the same PTS values and calculated corresponding times:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>PTS</th>
<th style="text-align: center;">0</th>
<th style="text-align: center;">512</th>
<th style="text-align: center;">1024</th>
<th style="text-align: center;">1536</th>
<th style="text-align: center;">2048</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Presen-tation time in seconds</strong></td>
<td style="text-align: center;">0*(1/15360)=<strong>0</strong></td>
<td style="text-align: center;">1*(1/15360)=<strong>1/30</strong></td>
<td style="text-align: center;">2*(1/15360)=<strong>2/30</strong></td>
<td style="text-align: center;">3*(1/15360)=<strong>3/30</strong></td>
<td style="text-align: center;">1*(1/15360)=<strong>4/30</strong></td>
</tr>
</tbody>
</table>
</div>
<p>Similar — but inverse — calculation is performed for your time values <code>-ss 0.989 -t 0.238</code>:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Required starting PTS</th>
<th>0.989 * 15360 = 15191</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Required ending PTS</strong></td>
<td><strong>(0.989 + 0.238) * 15360 = 18847</strong></td>
</tr>
</tbody>
</table>
</div>
<p>But frames with such PTS values in your input video don't exist, so FFmpeg will select frames with PTS <strong>15360</strong> (=30 * 512) and <strong>18944</strong> (=37 * 512), i.e. frame № 30 as a start frame and frame № 37 as an end frame.</p>
<p>There are 8 frames between frames 30 and 37 (inclusive), so the duration will be 8 * (1/30) = 8/30 seconds. It is the <em>exact</em> value. Your 0.27 seconds is the rounded one.</p>

CC BY-SA 4.0
2021-12-06T04:29:02.350Z
2021-12-06T05:11:23.117Z
2021-12-06T05:11:23.117Z
MarianD
<p>Can FFmpeg cut to a hundredth of a second?</p>
<p>When I try to cut a video using :</p>
<pre><code>ffmpeg -i input.mov -ss 0.989 -t 0.238 -r 30 -y output.mov
</code></pre>
<p>The video duration of output.mov is 0.27 seconds and not 0.238 seconds.</p>
<p>Is this something that is limited by the video frame rate?</p>
<p>This is the input video data:</p>
<pre><code>  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.29.100
  Duration: 00:00:04.43, start: 0.000000, bitrate: 12070 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 11995 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
      encoder         : Lavc58.54.100 libx264
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 133 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
</code></pre>
<p>This is the output video data:</p>
<pre><code> Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.29.100
  Duration: 00:00:00.27, start: 0.000000, bitrate: 15299 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 15144 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
      encoder         : Lavc58.54.100 libx264
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 123 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio
</code></pre>

<ffmpeg>
How accurately can FFmpeg cut a video to a specific duration?
user36611
# How accurately can FFmpeg cut a video to a specific duration?

(Asked by: username_0 on 2021-10-28)

Can FFmpeg cut to a hundredth of a second?
When I try to cut a video using :
ffmpeg -i input.mov -ss 0.989 -t 0.238 -r 30 -y output.mov

The video duration of output.mov is 0.27 seconds and not 0.238 seconds.
Is this something that is limited by the video frame rate?
This is the input video data:
  Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.29.100
  Duration: 00:00:04.43, start: 0.000000, bitrate: 12070 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 11995 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
      encoder         : Lavc58.54.100 libx264
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 133 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio

This is the output video data:
 Metadata:
    major_brand     : qt  
    minor_version   : 512
    compatible_brands: qt  
    encoder         : Lavf58.29.100
  Duration: 00:00:00.27, start: 0.000000, bitrate: 15299 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 15144 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
      encoder         : Lavc58.54.100 libx264
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 123 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio

**Tags:** ffmpeg


---

## 2 answers

### Answer by username_1 on 2021-11-05. Score: 3

I *believe* you cannot cut less than a frame dealing with video streams.

With 30 fps a single frame is 0.033(3) seconds.
The closest value for your requested 0.238 is 0.233(3). But it is less than needed and to not miss any data ffmpeg takes one more frame which results in 0.266(6). When rounded it is exactly 0.27.


---

### Answer by username_2 on 2021-12-06. Score: 2

> Is this something that is limited by the video frame rate?

Indirectly — if the input video stream has a fixed frame rate. The true reason is system of PTS.

Every frame has its so-called *presentation time stamp* (PTS), expressed as an *integer number*.

Your input video stream has probably these PTS:
[![enter image description here](https://i.sstatic.net/bqtKm.jpg)](https://i.sstatic.net/bqtKm.jpg)
What is the meaning of these integer numbers?

They are multiples of the *unit time* (a tick) for the stream.

* In your case, the unit time is as small as `1/15360` of second, because it is a *reciprocal value* of the so-called *time base*, and the time base for your input stream is 15360  
  (see `..., 15360 tbn, ...` in your listing).

Here are the same PTS values and calculated corresponding times:

| PTS | 0 | 512 | 1024 | 1536 | 2048 |
| --- | --- | --- | --- | --- | --- |
| **Presen-tation time in seconds** | 0\*(1/15360)=**0** | 1\*(1/15360)=**1/30** | 2\*(1/15360)=**2/30** | 3\*(1/15360)=**3/30** | 1\*(1/15360)=**4/30** |

Similar — but inverse — calculation is performed for your time values `-ss 0.989 -t 0.238`:

| Required starting PTS | 0.989 \* 15360 = 15191 |
| --- | --- |
| **Required ending PTS** | **(0.989 + 0.238) \* 15360 = 18847** |

But frames with such PTS values in your input video don't exist, so FFmpeg will select frames with PTS **15360** (=30 \* 512) and **18944** (=37 \* 512), i.e. frame № 30 as a start frame and frame № 37 as an end frame.

There are 8 frames between frames 30 and 37 (inclusive), so the duration will be 8 \* (1/30) = 8/30 seconds. It is the *exact* value. Your 0.27 seconds is the rounded one.


---

