Thursday, June 2, 2011

mplayer / mencoder / ffmpeg recipes

Concatenate AVI files
cat file1.avi file2.avi > big.avi
mencoder -ovc copy -oac copy -o out.avi -forceidx big.avi


Split video
From a start pos (4 mins 20 secs) to end:
mencoder -ss 00:04:20 -oac copy -ovc copy in.avi -o out.avi
From beginning to an end pos (11 mins 44 secs):
mencoder -endpos 00:11:44 -oac copy -ovc copy in.avi -o out.avi
From a start pos (4 mins 20 secs), extract 5 mins of video:
mencoder -ss 00:04:20 -endpos 00:05:00 -oac copy -ovc copy in.avi -o out.avi

Extract audio from video
mplayer -dumpaudio videoFile.avi -dumpfile audioFile.mp3
or
mplayer -ao pcm -vo null videoFile.avi
it dumps the audio to audiodump.wav

Best is to use ffmpeg:
ffmpeg -i <input media> -ss <bgn time> -t <duration> -acodec copy -vn <output file>
where:
  • -i input media is the source media (i.e. an avi file)
  • -ss bgn time: Seek to given time position in seconds.  "hh:mm:ss[.xxx]" syntax is also supported.
  • -t duration: duration of the segment to extract
  • output file: the output file, e.g. a mp3 file (depending on the input's audio encoding)
To encode the audio stream use a different -acodec option and see extra options (bitrate, etc.)

No comments:

Post a Comment