Skip to main content
45 events
when toggle format what by license comment
May 22 at 12:58 history edited slhck CC BY-SA 4.0
added 70 characters in body
May 22 at 12:40 review Suggested edits
May 22 at 12:57
Jan 11 at 18:17 comment added BallpointBen -copyts lets you use a -to timestamp from the original video, but contains an initial empty chunk of length START, where START is what was passed to -ss. To fix this, you can take the result of the command with -copyts, say tmp.mp4, and just copy it with ffmpeg -i tmp.mp4 -c copy out.mp4. The empty chunk will be gone and the timestamps will be correct.
S May 8, 2023 at 12:59 history suggested CommunityBot CC BY-SA 4.0
-map 0 maps all streams, audio, video and subtitles
May 8, 2023 at 12:11 review Suggested edits
S May 8, 2023 at 12:59
Apr 17, 2023 at 8:56 comment added kraftydevil @slhck It indeed creates a clip that is 4.166 seconds long. The first part of the generated video is black until it ends with the desired clip. I get the start/end values by manually finding what I want in DaVinci resolve, and then copying the timecode - being sure to convert frames to milliseconds. Playing them with Quicktime. I actually gave up on this method and decided to use '-t'. I ended up calculating the duration separately (endTime - startTime). It worked so I'm done pursuing. Thank you for your work!
Apr 16, 2023 at 9:01 comment added slhck @kraftydevil Your command should work, it shouldn't be 4.166 seconds long. How do you determine the length? Where did you play the clip? Maybe post a new question and show the full command line output that your command produces.
Apr 14, 2023 at 21:27 comment added kraftydevil I'm still getting a clip that is of duration length unfortunately. For example, when I try ffmpeg -copyts -ss 00:00:03.633 -i input.mp4 -to 00:00:04.166 -c:v libx264 -crf 23 -c:a aac -b:a 192k output.mp4 - I get a clip that is 4.166 seconds long and I want the duration to be the difference between 4.166 - 3.633, which is about half a second. In addition the clip is blank, but I'm trying to get the length correct first
Apr 14, 2023 at 15:25 comment added slhck @kraftydevil I updated the answer. It's a bit confusing with the use of -copyts, unfortunately.
Apr 14, 2023 at 15:25 history edited slhck CC BY-SA 4.0
added 832 characters in body
Apr 14, 2023 at 12:47 comment added kraftydevil It is noted that "if you've used -ss, you have to subtract this from the -to timestamp"...Can you give a concrete example of what things to subtract exactly and how you do that subtraction when milliseconds are involved?
Feb 18, 2022 at 11:18 review Suggested edits
Feb 18, 2022 at 11:59
Jul 19, 2021 at 8:44 history edited slhck CC BY-SA 4.0
added 221 characters in body
S Jul 17, 2021 at 5:58 history suggested LuisF CC BY-SA 4.0
clarify -to option, needs -copyts
Jul 16, 2021 at 16:09 review Suggested edits
S Jul 17, 2021 at 5:58
Mar 30, 2021 at 20:56 comment added Link-akro @stackexchange_account1111 to be fair the present answer links to the Seeking guide, which in turn explains -copyts etc. Leaving aside whether i had the rep or boldness to edit, the edit queue is full according to the system when i tried to edit just now.
Jan 6, 2021 at 18:38 comment added gargoylebident @Link-akro thank you so much! That did it! You should add that as the answer. Out of all the things I've tried on here this is the only method that reliably and accurately trims the video. Using latest stable ffmpeg.
Aug 23, 2020 at 8:54 comment added Link-akro -to does not always "start from" -ss even without -copyts, @Maggyero I use to move the -to option to configure the input instead of the output so it is just another solution. ffmpeg -ss [start] -to [stop] -i in.mp4 -c copy out.mp4 Like this my stop time is correct despite the start time. I wonder if it is also the reason why @lustig moved -ss to the output while they did not know why. The answer does not even mention -copyts ! It should, as it is the simplest solution here ! I prefer reordering the arguments, but i guess it is not simpler.
Mar 3, 2020 at 14:10 comment added slhck @Maggyero Good suggestion, added.
Mar 3, 2020 at 14:09 history edited slhck CC BY-SA 4.0
added 173 characters in body
Mar 3, 2020 at 13:42 comment added Géry Ogam I think you should mention that -to starts from -ss, not from the beginning of the original input, unless you add the -copyts option (cf. Cutting small sections).
Nov 22, 2019 at 14:22 comment added technoplato @slhck good question, and one where I'd have to check things out again to tell you. I'm a very novice user of FFmpeg, so mine should not be a canonical exception bur rather an anecdote.
Nov 21, 2019 at 9:02 comment added slhck @lustig Hm. Completely ignored, or was there an offset to what you specified? I think it depends on whether you hit a a keyframe or not… I just tried and putting -ss after the input made it inaccurate.
Nov 20, 2019 at 20:56 comment added technoplato Just the messenger here friend. Doing the way above did not work. The video start time I specified was ignored.
Nov 20, 2019 at 20:49 comment added slhck @lustig That should make no difference at all when stream copying.
Nov 20, 2019 at 18:58 comment added technoplato I had to put the -ss after the -i in.mp4 ffmpeg -i in.mp4 -ss 00:01:00 -to 00:02:30 -c copy out.mp4
Apr 14, 2019 at 19:17 history edited slhck CC BY-SA 4.0
remove legacy stuff
Dec 3, 2016 at 23:48 comment added Artem Russakovskii I just wanted to comment on how fast the cutting process is - on my Windows 10 Skylake PC, it took pretty much a split second to finish. I thought something went wrong at first, but nope - the new file was written and chopped off perfectly.
Feb 5, 2016 at 14:17 history edited slhck CC BY-SA 3.0
deleted 114 characters in body
Dec 30, 2015 at 10:54 comment added slhck @Yay295 I revised my answer to clarify that. Thanks for the comment—I'd have forgotten to do that otherwise.
Dec 30, 2015 at 10:54 history edited slhck CC BY-SA 3.0
added 49 characters in body
Dec 27, 2015 at 18:12 comment added Yay295 Ron Harlev - ffmpeg changed how it works some time ago so that it will be accurate no matter where you put the -ss. The fast method is still faster though.
Nov 17, 2015 at 18:50 comment added Ron Harlev The accurate method seems to produce exactly the same results as the fast one. I get the first 1-2 seconds as a frozen frame, while the audio plays normally.
Jul 3, 2015 at 12:36 comment added slhck @Prateek When copying the video bitstream (instead of re-encoding), you can only cut at keyframes. If there are keyframes at seconds 1, 2, and 3, but you want to cut at second 1.5, then ffmpeg will wait until second 2 before it can start cutting. That makes it inaccurate.
Jul 3, 2015 at 6:30 comment added Prateek Could you explain what frame accuracy means?
Jul 1, 2015 at 18:37 comment added bee.catt thank you! I was using: "ffmpeg -i in.mp4 -vf trim=duration=99 out.mp4" and it was giving me 1:44 output instead of 1:39 output, even when I reduced the duration to 98 and 90 sec, I still got a 1:44 output? Anyway, using your first example above, I got the correct output length.
Dec 16, 2014 at 8:44 history edited slhck CC BY-SA 3.0
added 502 characters in body
Apr 1, 2014 at 5:34 comment added slhck @Jeff Yes! (character minimum)
Mar 31, 2014 at 17:03 comment added Jeff Thanks for this! if you don't specify a duration, will it go to the end?
Oct 4, 2013 at 10:45 history edited slhck CC BY-SA 3.0
added 655 characters in body
Jul 24, 2013 at 18:57 history edited slhck CC BY-SA 3.0
added 113 characters in body
Apr 2, 2013 at 14:45 comment added slhck @Samuel Then you're using an outdated version, which isn't even real FFmpeg, but the Libav fork. See: stackoverflow.com/a/9477756/1109017
Apr 2, 2013 at 14:21 comment added Samuel Lampa On ubuntu 12:10, -c:v and -c:a didn't work. I had to use "-acodec copy and -vcodec copy" instead.
Oct 9, 2012 at 16:19 history edited slhck CC BY-SA 3.0
added 202 characters in body
Jan 11, 2012 at 21:02 history answered slhck CC BY-SA 3.0