Linux: Video Files Manipulation

Time to time it is necessary to convert between two video files. Use the following steps to move forward.

ffmpeg

To see a list of all the codecs/formats supported by FFmpeg, run the following command:

ffmpeg --formats

To convert a file with the default settings, run the following command:

ffmpeg -i InputFile OutputFile

Turn a video to X images, run:

ffmpeg -i video.mpg image%d.jpg

Encode a video sequence for the iPpod/iPhone:

ffmpeg -i InputFile.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb
-mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X OutputFile.mp4

To select a particular sequence from a videofile starting at a specific time and ending at a specific time, use:

ffmpeg -i "InputFile.mp4" -ss hh:mm:ss.ms -to hh:mm:ss.ms -c copy OutputFile.mp4

To select a particular sequence from a videofile starting at a specific time and lasting an exact number of seconds, use:

ffmpeg -i "InputFile.mp4" -ss hh:mm:ss.ms -t NumberOfSeconds -c copy OutputFile.mp4

Mencoder

Using mencoder (mplayer package):

mencoder Input.mpg -o Output.avi -oac OutputAudioCodec -ovc OutputVideoCodec

The input file can be of a different type (MPG, AVI, MKV, MP4, …). And the same stands for the output file.
To get the <OutputAudioCodec> options, use:

mencoder -oac help

To get the <OutputVideoCodec> options, use:

mencoder -ovc help

To use the best parameters the current system supports, use:

mencoder Input.mpg -o Output.avi -ovc lavc -oac lavc
Advertisements
This entry was posted in Audio/Video, Linux and tagged , , , , , , , , , , , . Bookmark the permalink.