<p>I try to figure out how to use FFmpeg to trim videos. I have created a 30 second <code>.mov</code> screen capture using Apple's QuickTime player, and then tried to trim it using three different ways:</p>
<ol>
<li><p>Using <code>-copyts</code>, without re-encoding</p>
<pre><code>ffmpeg -copyts -ss 00:00:10 -i input.mov -to 00:00:15 -map 0 -c copy output.mov
</code></pre>
</li>
<li><p>Using <code>-copyts</code>, with re-encoding</p>
<pre><code>ffmpeg -copyts -ss 00:00:10 -i input.mov -to 00:00:15 -c:v libx264 -crf 23 -c:a aac -b:a 192k output.mov
</code></pre>
</li>
<li><p>Using <code>-trim</code> (with re-encoding, which is the only option):</p>
<pre><code>ffmpeg -i input.mov -vf trim=10:15 output.mov
</code></pre>
</li>
</ol>
<p>No matter which approach I tried, the output video is always 15 seconds long and the first 10 seconds of that is just a black screen, whereas what I expected is a 5-second video and without the black screen.</p>
<p>All the three solutions are from here: <a href="https://superuser.com/questions/377343/cut-part-from-video-file-from-start-position-to-end-position-with-ffmpeg">https://superuser.com/questions/377343/cut-part-from-video-file-from-start-position-to-end-position-with-ffmpeg</a> (answers by <a href="https://superuser.com/users/48078/slhck">@slhck</a> and <a href="https://superuser.com/users/106444/malat">@malat</a>), and are very high-voted, so I expect they should work without issues, but they don't. Why is that? Is there a problem with the commands, or with the video?</p>
<p>The video is uploaded here: <a href="https://github.com/jsx97/test/blob/main/input.mov" rel="nofollow noreferrer">https://github.com/jsx97/test/blob/main/input.mov</a></p>

CC BY-SA 4.0
2024-06-12T01:12:40.267Z
from doc: `-copyts → Do not process input timestamps, but keep their values without trying to sanitize them. In particular, do not remove the initial start time offset value.` If use trim, add setpts `-vf trim=10:15,setpts=PTS-STARTPTS`
Баяр Гончикжапов
CC BY-SA 4.0
2024-06-12T07:59:13.387Z
@БаярГончикжапов That is, if using `-copyts`, this is a natural behavior? Then this is somewhat strange that "how to trim a video using FFmpeg" solutions , which are often based on `-copyts`, don't mention this "black screen" issue.
jsx97
CC BY-SA 4.0
2024-06-12T08:03:00.257Z
maybe, it can be used to syncronize videos from surveillance cameras
Баяр Гончикжапов
CC BY-SA 4.0
2024-06-12T08:08:08.773Z
@БаярГончикжапов And when you need to trim a video, which approach you use yourself, `-trim` or something else?
jsx97
CC BY-SA 4.0
2024-06-12T08:10:12.003Z
mostly, `ffmpeg -ss 5 -to 15 -i in out`
Баяр Гончикжапов
<ffmpeg>
Trimming a video using FFmpeg leads to black screen
jsx97
# Trimming a video using FFmpeg leads to black screen

(Asked by: username_0 on 2024-06-11)

I try to figure out how to use FFmpeg to trim videos. I have created a 30 second .mov screen capture using Apple's QuickTime player, and then tried to trim it using three different ways:

Using -copyts, without re-encoding
ffmpeg -copyts -ss 00:00:10 -i input.mov -to 00:00:15 -map 0 -c copy output.mov


Using -copyts, with re-encoding
ffmpeg -copyts -ss 00:00:10 -i input.mov -to 00:00:15 -c:v libx264 -crf 23 -c:a aac -b:a 192k output.mov


Using -trim (with re-encoding, which is the only option):
ffmpeg -i input.mov -vf trim=10:15 output.mov



No matter which approach I tried, the output video is always 15 seconds long and the first 10 seconds of that is just a black screen, whereas what I expected is a 5-second video and without the black screen.
All the three solutions are from here: https://superuser.com/questions/377343/cut-part-from-video-file-from-start-position-to-end-position-with-ffmpeg (answers by @slhck and @malat), and are very high-voted, so I expect they should work without issues, but they don't. Why is that? Is there a problem with the commands, or with the video?
The video is uploaded here: https://github.com/username_0/test/blob/main/input.mov

**Tags:** ffmpeg

> **Comments:**
> **username_1**: from doc: `-copyts → Do not process input timestamps, but keep their values without trying to sanitize them. In particular, do not remove the initial start time offset value.` If use trim, add setpts `-vf trim=10:15,setpts=PTS-STARTPTS`  
> **username_0**: @БаярГончикжапов That is, if using `-copyts`, this is a natural behavior? Then this is somewhat strange that "how to trim a video using FFmpeg" solutions , which are often based on `-copyts`, don't mention this "black screen" issue.  
> **username_1**: maybe, it can be used to syncronize videos from surveillance cameras  
> **username_0**: @БаярГончикжапов And when you need to trim a video, which approach you use yourself, `-trim` or something else?  
> **username_1**: mostly, `ffmpeg -ss 5 -to 15 -i in out`  

---

## 0 answers

