The Computer Oracle

Is it possible to use ffmpeg to trim off X seconds from the beginning of a video with an unspecified length?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Future Grid Looping

--

Chapters
00:00 Is It Possible To Use Ffmpeg To Trim Off X Seconds From The Beginning Of A Video With An Unspecified
01:38 Accepted Answer Score 60
01:53 Answer 2 Score 30
02:39 Answer 3 Score 12
02:50 Answer 4 Score 4
03:17 Answer 5 Score 0
03:50 Thank you

--

Full question
https://superuser.com/questions/258032/i...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#video #ffmpeg #mencoder

#avk47



ACCEPTED ANSWER

Score 60


Try:

ffmpeg -i input.flv -ss 2 -vcodec copy -acodec copy output.flv

I think the input parameter is supposed to be first.




ANSWER 2

Score 30


Turns out this command will trim the video from 2 seconds on, as expected:

ffmpeg -i input.flv -ss 2 -vcodec copy -acodec copy output.flv

The issue was with the keyframe interval in input.flv. It was set to 5 seconds, which yielded 3 seconds worth of black frames at the beginning of the video (5 - 2 = 3). I've since changed my keyframe interval to 1 second, though 2 seconds would probably also yield the desired results in my case.

UPDATE: Updated ordering of -i and -ss parameters per Dave's answer, which I've accepted for credit.




ANSWER 3

Score 12


Use -ss and -to before -i like this:

ffmpeg -ss 00:01:10 -to 00:02:10 -i input -c copy output



ANSWER 4

Score 4


It sounds like there might be additional codec parameters required for video, but this worked to trim the first 5s off an mp3 file for me (similar to Bora Savkars Answer, though his solution output the part I wanted to trim instead of the file I wanted, minus the first 5s)

ffmpeg -ss 00:00:05 -i input -c copy output

https://ffmpeg.org/ffmpeg.html




ANSWER 5

Score 0


Using -vcodec copy was also causing me to have a poorly functioning video at the point of the trim.

ffmpeg -i nick.mp4 -ss 52 -vcodec libx264 0 -acodec copy nick4.mp4

Is what I was able to use to accomplish a properly working video trimmed where I wanted it. (Thanks to Karl Wilbur for the hint in one of the comments to an answer)