-   Linux - General (
-   -   How to reduce video file size? (

leosgb 03-25-2007 08:30 PM

How to reduce video file size?

I am trying to reduce some video files I have so that I can transfer then to my pda. These files are "small" in a desktop sense but copying many 300MB files to my pda takes a long time and besides the screen is tiny anyway so I am keeping info that I dont need and wasting precious disk space.

Does anyone have a recipe to use mplayer or anything like it to do this? I would like to keep the same video quality, just reduce the video size to loose some of the fat to produce the bigger image in my desktop. I dont want to drop frames and I dont need to change encoding formats.

Any help is appreciated. Thanks in advance.

SciYro 03-27-2007 05:51 AM

Mplayer also comes with "mencoder", which will allow you to re-encode video files. And yes, you do need to re-encode because what you want requires altering the existing video information from within its current codec, this can only be done by re-encoding things.

Using mencoder is a pain tho. First, what codec is the current video in? Using "copy" for the audio should be fine, and "lavc" for the video codec. Use the "scale" option with the video filter to scale things.


mencoder input -vf scale=320:200 -oac copy -ovc lavc -lavcopts vcodec=mpeg4 -o outut
That should work, resizing to 320x200 using the mpeg4 codec. Not sure how good mencoder is at guessing quality, so if your video is already crappy quality, you might want to think about lower the quality settings. Since there is so many options, and i find it all to boring, ill just leave that out, read mencoders man page if you want to learn tho, under "-lavcopts".

leosgb 06-05-2007 08:37 PM

Hi SciYro, I tried your suggestion here several times. My movies are 352x238, 640x480, 352x240 and 448x336. My goal is to reduce the file size without loosing quality.

I tried to reduce a 352x238 movie to 300x200 (as in your example) and then to 150x100. But the file changed from: 162.035.712 bytes to: 118.582.492.

This is not what I was expecting. I thought that by reducing the screen size by a factor of 2 I would get a reduction in file size of the same order. Am I wrong? Is there any way to do what I am saying but keeping the quality?

Thank you!

leosgb 06-05-2007 10:27 PM

I tried using xvid codec and got: 105.500.906 (with 150x100). So I guess one of the ways is to find the best codec. Is it possible to make it go thru the codec several times to improve the compression?

dawkcid 06-07-2007 12:56 PM

Finding the best quality vs size is, unfortunately, not an exact science. You'll just need to experiment a little. Be sure to read the mplayer man page carefully, there are LOTS of options to tweak mencoder. You should also read the mencoder documentation (should be at /usr/share/doc/MPlayer-(version)/html/mencoder.html) for encoding tips. By the way, the biggest factor in file size (and quality) is not the resolution, but the video bitrate.

leosgb 06-07-2007 02:10 PM

I see, but shouldnt I get a much smaller file if I have much smaller frames? That is assuming I dont touch the bitrate, after all if each frame has a given number of bits and I keep the bitrate but transfer less bits I would expect a smaller file. Feel free to correct me if I am wrong.

I will try it again with xvid codec. And will also play around with the bitrate. Can mencoder be smart and notice that I am reducing the screen resolution but since I dont state anything about bitrate it increases my bitrate "automagically"?

I will post back my results once I get some numbers to compare.

Thanks for your tips!

dawkcid 06-08-2007 08:36 AM

The bitrate is the number of bits (or kilobits) _per second_, not _per frame_, you still have the same number of frames per second. If you have the same bitrate but reduce the resolution, you just increase the number of bits used per frame compared to a higher resolution.


Can mencoder be smart and notice that I am reducing the screen resolution but since I dont state anything about bitrate it increases my bitrate "automagically"?
Not that I've noticed. If you don't specify a bitrate it will just use some default value, which seems to be the same regardless of resolution. AFICT anyway.

Also, I forgot to mention /usr/doc/MPlayer-(version)/tech/encoding-tips.txt. There are some good tips in here, I improved the quality of my encodings dramatically by using some of these suggestions. Especially, you should always use vhq or mbd=1 (same thing) or maybe mbd=2. The default is mbd=0, if you use this you probably want to change the mbcmp option to something other than 0 (see mplayer man page for details).

DiBosco 06-11-2007 06:51 PM

Would acidrip help with this? I think it might be worth having a play with it anyway...

dawkcid 06-14-2007 10:38 AM

I don't think it will help in this case. Acidrip is for ripping dvds, not sure it can encode from files. It's just a frontend to mplayer/mencoder anyway.

DiBosco 06-15-2007 12:43 PM

I've used acidrip for converting MPEG files (of programmes I've backed up from my Sky+ box) to AVIs, so it's definitely not just for ripping DVDs. It looks to me like you can choose crop and scale options, so it might be worth playing about with. I appreciate it's just a front end for other command line programs; can memcoder definitely not do what you're after?

All times are GMT -5. The time now is 03:27 AM.