Hi Laurent, > I might be wrong as I don't have an in-depth knowledge of MPEG2 and MPEG4 > compression, but it seems to me that MPEG4 compression is more time > consumming than MPEG2. > > I know that mpeg2enc is a professional-quality tool that can give extremely > good quality MPEG2 streams. Well... its got a little way to go before its professional quality...
> However, I'd like to know if anyone has ever > profiled mpeg2enc to find where the performance bottleneck is. I don't > expect mpeg2enc to give me real-time encoding performances (quality comes > at a cost), but 3fps seems very low compared to 25fps. Errr... not just 'ever'. I *regularly* profile mpeg2enc. The main bottleneck is motion estimation especially if B frames are being used. Here's why there's such a big difference: 1. Size of frame. Processing resources rise with nearly the cube of frame size when you compare like with like. Why? Easy, you increase the number of pixels by the square of frame dimensions. However, to keep your motion estimation radius the same (in terms of fractions of a frame) that has to increase too so the area you search for each macroblock increases by the square of dimensions too. 2. B Frames. B Frames are nasty because you have to motion estimate not over a single frame interval but 1 frame in one direction and 2 frame intervals in another. If you want to cover motion of a given speed you have to search 5 (1+2*2) times as many pixel positions as if you were doing simple back-to-back P frames. The P frames that come every 3rd frame need to cover 9 times as many pixels compared with back-to-back P frames. 3. Interlaced motion modes. If you leave the interlaced motion estimation on mpeg2enc motion estimates on a frame *and* a field basis. This nearly doubles the amount of work it has to do. 4. Type of motion estimation. mpeg2enc uses a relatively expensive hierarchical exhaustive motion estimation search. This means you have a high probability of finding a rather good or even optimal motion vector. You can do 'nearly' as well using predictor/corrector motion estimation algorithms which are many times faster. 5. The use of variance based encoding mode selection. Sum of absolute differences is would be much faster and nearly as good. 6. A sub-optimal encoding data-flow inherited from the original MSSG reference encoder. A couple of bits in mpeg2enc are just not terribly well thought out for speed. So, to compare like with like you have to compare default mpeg2enc and MPEG-4 encoder encoding full CCITT 720x<Y> pictures with interlaced motion modes active and a BBP picture structure *and* identical pre-encoder processing. If you want to encode MPEG2 SVCD/DVD fast with mpeg2enc. You should: - Turn off interlaced mode if it is not needed. Basically, any movie material! - Go to P frames only (this may sometimes even improve compression!). For example, on my 1700Mhz Athlon/XP, 243 Frames of NTSC (720x480) Movie Note: this is just the encoder. It is common for the MJPEG decoding and denoising/scaling etc etc to use pretty much the same CPU resources. INFO: [lt-mpeg2enc] Frame end 224 B quant=8.52 total act=17159.02351 -f 8 -E -10 -q 6 -K tmpgenc user 0m34.014s = 7.1 Frame/sec -f 8 -E -10 -q 6 -R 0 -I 0 -K tmpgenc user 0m14.580s = 16.6 Frame/sec Now if we go to smaller frames SVCD (480x480) -f 4 -E -10 -q 6 -K tmpgenc user 0m23.770s = 10.3 Frame/Sec -f 4 -E -10 -q 6 -R 0 -I 0 -K tmpgenc user 0m9.900s = 24.5 Frame/sec Now if we go to smaller frames still VCD (352x240) -f 1 -E -10 -q 6 -K tmpgenc user 0m4.50s = 54 Frame/Sec -f 1 -E -10 -q 6 -R 0 -K tmpgenc user 0m4.140s = 58 Frame/Sec As you can see. The encoder just about reaches real-time performance on MPEG-4 typical stream resolutions and format. If a predictor/corrector motion estimator were added it would it would easily hit real-time performance on modest hardware. Andrew ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Mjpeg-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/mjpeg-users