Saturday, June 6, 2009

splitting a video file using mencoder

Just got asked from a friend to do video cutting, just to fetch the video and mp3 for portion of time 01:07:26 to 01:09:49

Here's what i did after after googling around for some great resources.

To get the range-cutted video, we need to do a two-steps process :

mencoder -endpos 01:09:49 -ovc copy -oac copy in.avi -o out.avi

in.avi is the original avi file
out.avi is the cutted avi file, starting from the beginning to 01:09:49 (hh:mm:ss) of in.avi

mencoder -ss 01:07:26 -oac copy -ovc copy out.avi -o out2.avi

out.avi is the output of the previous step
out2.avi is the final avi file, starting from 01:07:26 (hh:mm:ss) of out.avi till the end of it

Now, the last part, is to extract audio from the cutted video clip

mencoder out2.avi -of rawaudio -oac mp3lame -ovc copy -o file.mp3

The outputs are, out2.avi for the video and file.mp3, the audio extracted from out2.avi