Can I control quality (quantizer level) in XVID

Can I control quality (quantizer level) in XVID

Postby Mister-T » 14 Apr 2009, 22:25

I want to convert videos from various Fuji cameras to AVI (MPEG4 [xvid] video + MP3 audio) as they are recorded in the very inefficient MJPEG video + PCM audio format.
I want to maintain quality and I usually do it in AVIDEMUX and set the quantizer level (at say 5 or 6). The bitrate then varies widely (500 - 3000kbps) depending on the filmed subject.
Is there a way to control quantizer level rather than bitrate.
Mister-T
 
Posts: 9
Joined: 14 Apr 2009, 22:01

Re: Can I control quality (quantizer level) in XVID

Postby Team Cocoon » 15 Apr 2009, 14:45

Hello and welcome ,

If you know how to use ffmpeg in command line you can always try to use specific commands in the expert mode and activate the command line feature, then you can enter your command line in the box used for that purpose.

Hope this helps .
Ps make sure you look at the ffmpeg version first before writing your command line , these commands vary accordingly with the version number...

Have a nice day.
Team Cocoon
thx for donating
http://www.cocoonsoftware.com/paypaldonate-us.htm
User avatar
Team Cocoon
Site Admin
 
Posts: 1301
Joined: 24 Sep 2007, 20:01

Re: Can I control quality (quantizer level) in XVID

Postby Team Cocoon » 15 Apr 2009, 18:06

After talking to Gilles here is an example of command line for quantising ,

-maxrate 2500k -b 2000k -qmin 3 -qmax 5 -bufsize 4096 -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -g 300


Have fun ,

Have a nice day.
Team Cocoon
thx for donating
http://www.cocoonsoftware.com/paypaldonate-us.htm
User avatar
Team Cocoon
Site Admin
 
Posts: 1301
Joined: 24 Sep 2007, 20:01

Re: Can I control quality (quantizer level) in XVID

Postby Mister-T » 16 Apr 2009, 15:46

Thanks,
Found useful info for ffmpeg at http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
Eventually got my preferred command line to be this (using "use command line only" option) :

-vcodec xvid -r 30 -qscale 7 -s 640x480 -acodec mp3 -ar 22050 -ab 64k

Explained:
- XVID video codec;
- frame rate 30;
- constant quantizer of 7 (2 is best quality, 31 is worst);
- 640x480 resolution (also called 'vga');
- mp3 audio codec (I guessed this!);
- resample to 22050Hz (needed for my low freq. audio otherwise mp3 doesn't work);
- force mp3 bitrate to 64kbps (yes I know this is the default but better to be sure...).

If you don't put the video codec in you get FMP4 encoding which gives a similar (slightly smaller) file size, faster conversion but possibly not as good quality? If you don't put the audio codec in you get MP2 audio.

So the shortest command line for constant quality is really
-r 30 -qscale 7 -s vga -ar 22050
but I'll use the top one!
Mister-T
 
Posts: 9
Joined: 14 Apr 2009, 22:01

Re: Can I control quality (quantizer level) in XVID

Postby Mister-T » 16 Apr 2009, 19:38

I've had a second look and the ffmpeg (FMP4) conversion is very fast compared to XVID (and compression is slightly better).
Only problem is the FMP4 format has had compatibility issues just because early players didn't know what it was. So I'm using the command -vtag xvid to label it as a XVID file

-vtag xvid -r 30 -qscale 6 -s 640x480 -acodec mp3 -ar 22050 -ab 64k

I'm going to play with quality settings next ... I hope that doesn't slow it down!
Mister-T
 
Posts: 9
Joined: 14 Apr 2009, 22:01

Re: Can I control quality (quantizer level) in XVID

Postby Mister-T » 16 Apr 2009, 21:17

Another update:
Starting with the same clip each time and adding just the following:

-bf 1 -b_qoffset 3 (1 B frame) made a 3.5% reduction in file size but slowed from 67fps to 35fps (so not worth it for speed sake).
-bf 2 -b_qoffset 3 (2 B frames) made the files 4% smaller.
-mbd 1 made the file 1% smaller (59fps)
-mbd 2 made the file 0.8% smaller.
-aic 2 made it 2% smaller (66fps).
-g 150 (an I frame every 5s) made it 16% smaller (wasn't expecting that) and a file with more I frames is easier to scan.
-g 100 made it 15% smaller (62fps)

current choice line runs (55fps) - (should I have -f avi at start?)

-vtag xvid -r 30 -qscale 7 -s vga -g 150 -aic 2 -mbd 1 -acodec mp3 -ar 22050 -ab 64k

Hope this of use to someone ... anyone ...
Mister-T
 
Posts: 9
Joined: 14 Apr 2009, 22:01

Re: Can I control quality (quantizer level) in XVID

Postby Mister-T » 17 Apr 2009, 09:09

To convert camera MJPEG videos to MPEG4 video + MP3 audio with minimal loss of quality
More testing and now I'm using:

-vtag xvid -r 30 -qscale 5 -g 150 -aic 2 -mbd 1 -flags +4mv+umv -acodec mp3 -ar 22050 -ab 64k

I've removed the size parameter (default is output=input) and I've 2 resolutions.
Added '4mv' and 'umv' - tried trell (as in your example) but file size was bigger (unlike in xvid on avidemux where it gets smaller) so it may be that the flag is incorrect?

For qscale = 5 compression is over 70% (e.g. 20MB > 5.3MB)
For qscale = 7 compression is over 80% (e.g. 20MB > 3.4MB)

"FMP4" tagged avi's don't work (video part) on WMP but the above tagged with "XVID" work on WMP, Realplayer, Winamp, Mplayer, Divx etc...

Where can I find more documentation for ffmpeg - the link I gave earlier is slightly incomplete (no explanation of aic params, and no 'trell' option for example) ?
Mister-T
 
Posts: 9
Joined: 14 Apr 2009, 22:01

Re: Can I control quality (quantizer level) in XVID

Postby Cocoon-Dev » 17 Apr 2009, 18:56

Thank you to share yours knowedges.
The best for me,it is to use alls options in ffmpeg and it is also to go read the technical iso info's in the wiki.
Now the best, it is to try each option and i check the result.
We come back with mores info's in the futur and we you, if you want.

have a nice day.
thx for donating
http://www.cocoonsoftware.com/paypaldonate-us.htm
Team Cocoon
User avatar
Cocoon-Dev
Site Admin
 
Posts: 1128
Joined: 24 Sep 2007, 00:54

Re: Can I control quality (quantizer level) in XVID

Postby fwupow » 24 Oct 2009, 22:14

Team Cocoon wrote:After talking to Gilles here is an example of command line for quantising ,

-maxrate 2500k -b 2000k -qmin 3 -qmax 5 -bufsize 4096 -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -g 300


I'm trying to break this down according to the currently published ffmpeg documentation. So we've got:

-maxrate 2500k (maximum video bit-rate in bits/second)

-b 2000k (average video bitrate in bits/second)?

-qmin 3 (minimum quantizer scale, whatever that means)

-qmin 5 (maximum quantizer scale)

-bufsize 4096 (video buffer verifier buffer size (in bits), have no idea what this is about or how the size is determined)

-mbd 2 (Macro block decision = rate control, have no idea what this is either)

-flags (doesn't exist in ffmpeg documentation)

+4mv (currently '-4mv' in ffmpeg documentation, (Use four motion vector by macroblock (MPEG-4 only))

+trell (doesn't exist in ffmpeg documentation)

-aic 2 (Enable Advanced Intra-coding (h263+). ffmpeg doc does not list or explain available settings )

-cmp 2 (doesn't exist in ffmpeg documentation)

-subcmp 2 (doesn't exist in ffmpeg documentation)

-g 300 (gop size, set the Group of Pictures size (# of frames)) (I'm guessing this is the same as what DivX calls the "Max Keyframe Interval")
fwupow
 
Posts: 7
Joined: 23 Oct 2009, 20:24


Return to Expert Users Mode

Who is online

Users browsing this forum: No registered users and 2 guests

cron