Survival guide for standalone mpeg4 player
1.Standalone mpeg4 player
So you got a new shiny "divx" certified standalone dvd player but have problems with it. This small doc tries to help you make it play your videos.
2.The packed vop hack
B frames are nice but they induce a one frame delay shift because a b frame needs both its previous and next I/P frames to be decoded.
That does not cope very well with VFW (video for windows) limitation that more or less assume one frame in/ one frame out.
To workaround this, DivxNetork introduced PB frame in avi. To explain it see the b-frame doc.
Basically they add a non coded image (N-vop) after an frame containing both a P and a B frame. Some (most?) players choke or stutter on that as it creates artificially additionnal frame. To detect that, they put also a specific marker in the user data section of the mpeg4 stream. Some players use that information to switch to packed vop mode, but it is not 100% reliable. Plus the stream is not 100% iso compliant.
- Rule #1 : Dont use packed frames. With avidemux you can't but with some other software you can.
- Rule #2 : If you have some, depack them.
In order to do so, when prompted if avidemux should depack such frame, say yes. Avidemux will take each frame and scan for more than one vop inside it. If it finds several it re-creates separate frames and destroy the corresponding N-vop frames.
That will take care of the packed vop, but the marker in user data will remain. to also remove it, use save unpacked vop instead of the usual save video.
That will scan and fix on the fly the marker so that the stream are detected as non packed stream.
That should solve all Divx packed file, but may not work for some xvid files.
Warning: If the file has VBR audio, don't forget to do a Misc/Build VBR map after loading it. |
If you have a huge amount of such files to convert you can use a script like:
Code listing .1 |
#!/bin/bash
export SRC=/tmp/fma2
export TGT=/tmp/fma3
perl foreach.pl $SRC/*.avi "avidemux2 --force-unpack --load $SRC/%f --audio-map --save-unpacked-vop $TGT/fixed_%f --quit"
|
3.GMC and Qpel
Xvid and lavcodec can use more complete GMC (global motion compensation) and Qpel
(Quarter Pixel) models than divx codec.
With those, you are screwed and need to re-encode the video
That means dual-pass encoding to keep the same size.
There is a way to get almost the same result using only one pass.
Assuming your video is correctly done, the previous encoding already distributed quantizers and bitrate to get a good quality for a given size.
Why not reuse that information ?
To do so, set xvid (or lavcodec) to use Follow mode. In that mode, they will encode each frame with the quantizer used previously to encode it.
The result will have about the same size/quality compared to the original but using only one pass.
That can be done using cli mode also to process plenty of files in a row :
Code listing .1 |
#!/bin/bash
export SRC=/tmp/fma2
export TGT=/tmp/fma3
perl foreach.pl $SRC/*.avi "avidemux2 --force-unpack --load $SRC/%f --audio-map --video-process --video-codec xvid4 --video-conf follow=1000 --save $TGT/fixed_%f --quit"
|
4.Muxing
I have found that some software (like some version of nandub) does not mux properly the file. That makes standalone stutters and freeze. The fix is simple
: just load and save the file in avidemux2
|