Video conversion in linux

From Nocrashwiki
Revision as of 14:11, 5 August 2010 by Chris (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Howto do video conversion in linux

Convert a bunch of JPEGs into a .yuv file

jpeg2yuv -f 25 -I p -j conv-new-testA2B3-%05d.jpeg > result.yuv

Convert .yuv file into a MPEG

mpeg2enc result.yuv -o result.m2v

Go directly from JPEG files to MPEG file

jpeg2yuv -f 25 -I p -j image%05d.jpg | mpeg2enc -o mpegfile.m2v

Add sound to the stream

lavaddwav stream_without_sound.avi sound.wav stream_with_sound.avi

Convert result.m2v to a .mov file

ffmpeg -i result.m2v

To run make a bunch of images a uniform size with extra space black

for i in *.jpeg; do montage -geometry 352x240 -background black -quality 100 $i conv-$i; done

To create an animated Gif File. -loop 0 (loop forever); -delay 250 (250 hundredths of a second between images)

convert -delay 250 -loop 0 sm-files* file.gif 

Rotate Video

mencoder -vf rotate=1 -ovc lavc -oac copy mvi_Carolee.avi -o CaroleeVideo.avi


   * 0 Rotate by 90 degrees clockwise and flip (default).
   * 1 Rotate by 90 degrees clockwise.
   * 2 Rotate by 90 degrees counterclockwise.
   * 3 Rotate by 90 degrees counterclockwise and flip. 

Use mencoder to convert a file from MJPEG to MPEG4

mencoder -ovc lavc -lavcopts vcodec=mpeg4 -vop scale=432:320 -oac mp3lame -srate 22050 infile.avi -o outfile.mpg

    -ovc lavc  # use lavc video codec
    -lavcopts vcodec=mpeg4   # use mpeg4 option to lavc
    -vop scale=432:320   # resize video
    -oac mp3lame   # use mp3lame to encode audio
    -srate 22050   # resample audio to 22050 Hz

Convert a .wav file to .mp3

lame -h -b 192 in.wav out.mp3

More info here