Friday, June 22, 2007

Converting video and extracting audio from a video

Converting video formats into another

To convert mkv format to dvd format:

ffmpeg -i myfile.mkv -target dvd -copyts -aspect 16:9 myfile.mpg

To convert mp4 video to avi:

mencoder video.mp4 -ovc lavc -vf scale=352:288 -oac lavc -o video.avi

To convert avi to mpeg video:

ffmpeg -i video.avi -target pal-vcd video.mpg

or

ffmpeg -i video.avi -target pal-vcd -s 352x192 -padtop 32 -padbottom 32 video.mpg

Note: -target pal-vcd is for PAL. For NTSC, use -target ntsc-vcd. -padtop 32 and -padbottom 32 will add black padding at the top and bottom.

In certain cases, if you have problem with de-sync audio for the resulted mpeg, try using mencoder like this for PAL format VCD:

mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \
scale=352:288,harddup -srate 44100 -af lavcresample=44100 -lavcopts \
vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:\
vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 25 \
-o movie.mpg movie.avi

More options can be found here.

To convert avi to SVCD format:

ffmpeg -i video.avi -target pal-svcd video.mpg

Note: -target pal-svcd is for PAL. For NTSC, use -target ntsc-svcd.

Burn to CDs
This command will cut the mpeg video files into 3 to fit 3 CDs.

mpgtx -3 video.mpg -b m

The resulting file will be m-1.mpg, m-2.mpg and m-3.mpg. These files can be burnt to one CD each. The argument -b means basename.

or you can also use avisplit to split AVI movie:

avisplit -s 700 -i video.avi

Where to get the tools?
If you use Fedora, you can install all of the tools with yum. For other distro, please consult the manual for it. avisplit is part of transcode package.

Fixing desynched audio

avisync is easy to use: just provide an input file (-i name.avi), an output file (-o newname.avi) and the synchronization offset in frames (-n count). From avisync's help: count>0: audio starts with frame 'count'. count>0: prepend 'count' padding audio frames.

An example:
avisync -i ally-not-synched.avi -o ally-synched.avi -n -2

Splitting AVIs

avisplit -i ally-big-file.avi -o ally -s 700

This will produce files named ally-0000.avi, ally-0001.avi etc. that are each 100megs big at most.

Extracting audio from VOBs/MPEGs/AVIs

MPlayer can be used easily to extract sound. The -vo null options tells MPlayer not to show the video.
I'm not listing all possible options. Generally use -dumpaudio -dumpfile newaudio.extension if you want to extract the audio without processing and -ao pcm -aofile newaudio.wav if you want the WAV itself.

Using separate audio files

Sometimes you want to play another audio file along with your video. MPlayer makes this rather easy: mplayer -audiofile anotherlang.mp3 myvideo.avi plays video from myvideo.avi and audio from anotherlang.mp3. A lot of Windows media players support external audio files, too. This way you can provide several language versions as separate audio files. A combination often used is to have the AVI include the English audio track and to provide additional audio tracks in separate files.

A visual AVI editor: avidemux

If you've done video editing with Windows before you probably know the excellent OpenSource editor VirtualDub. An OpenSource utility for Linux that aims at providing the user with a similar set of features is avidemux. You can use it in order to easily cut specific parts from a movie, to apply filters, to reencode movies and to do a lot more. I suggest you take a look at it even if using the command line is as natural to you as it is for me.

Credit to :
moritz@bunkus.org (http://www.bunkus.org)
Gentoo Wiki (http://gentoo-wiki.com/HOWTO_Create_a_VCD_or_SVCD)
MPlayer Doc (http://www.mplayerhq.hu/DOCS/HTML/en/index.html)

0 comments:

Post a Comment