Monday, March 21, 2011

Converting video from ameg to avi with ffmpeg

I have been using my Sony SCR SX 20 for quite a some time now. One of the the problem I see is that even though it does not record in High Definition (HD) , it consumes a lot of space.In fact for 22 Minutes of High Quality video it creates a .MPEG file with size 1.5 Gb. This is too large for uploading in any video sites like YouTube. I tried Linux GUI Tools like WinFF and Avidemux  but they elongated the video vertically and also sometimes conversion failed because of some library missing issue.

I found it can be done with ffmpeg and desired optimal quality can be achieved gaining some free space.

For best quality
ffmpeg -i 1.MPG -sameq 1.avi

For desired quality
ffmpeg -i infile.MPG -qmax 4 outfile.avi

Here the number 4 indicates that I need a moderate quality , higher the number lower is the quality and smaller is the output file size. You can hit and trial with a small file and choose your desired number. Same is applicable while converting MOV file to avi.

For Batch processing one can try
??for f in *.MPG; do ffmpeg -i "$f" -qmax 4 "${f%.MPG}.avi"; done