Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg command to extract first two minutes of a video

Tags:

ffmpeg

What would be the simplest ffmpeg command to truncate the video to the first two minutes (or do nothing if the video is less than two minutes) ? It can do a pass-through on any of the initial video settings.

like image 905
David542 Avatar asked Oct 17 '14 19:10

David542


2 Answers

$ ffmpeg -i in.mov -ss 0 -t 120 out.mov
like image 127
David542 Avatar answered Oct 05 '22 03:10

David542


This is an adapted version of David542's post since my edit was rejected as "completely superfluous or actively harm[ing] readability".

For extractions, it is essential to add the -c copy flag,

ffmpeg -i in.mov -ss 0 -t 120 -c copy out.mov

what is shorthand for -vcodec copy -acodec copy. Otherwise ffmpeg reencodes the selection what is about 1000 times slower on my machine here and possibly alters the outcome in quality due to default settings taken.

like image 39
Suuuehgi Avatar answered Oct 05 '22 03:10

Suuuehgi