MJPEG vs. MPEG-4 encoding time
I am testing the encoding performance (MPEG-4 and MJPEG) of a smart camera. I have written an application in OpenCV/FFMPEG for performing encoding, where the application captures images from the camera and encodes 开发者_开发技巧them to a desired encoding format. In the benchmarks, I came to know that MJPEG encoding is taking much longer than MPEG-4 encoding. I expected it to be other way around. Encoding a single frame to MPEG-4 takes around 31ms, whereas encoding to MJPEG takes around 80ms. Does MJPEG really takes such a long time in comparison to MPEG-4?
MJPeg is faster theoretically, essentially because there is no inter-frame compression.
However there are ways that MPEG-4 could be faster. Here are a few factors to consider:
MPEG-4 can actually be two different formats, either "Part 2" or "Part 10", and Part 2 is much faster. See here for details: http://en.wikipedia.org/wiki/MPEG-4_Part_2.
The settings for the encoder can make an order of magnitude
difference. Fast settings for a given format can be 10x or more
faster than the same format with slower settings (speed/quality
tradeoffs).The encoders for MPEG-4 are some of the most optimized pieces of code on the planet. They still heavily use assembly language. They could easily be faster in practice than another format that is not heavily optimized.
If your IO is slow (network, hard drive) this can skew the results.
For example having no compression is the fastest right? But it takes time to write larger files.
So in practice, MJPEG could possibly be slower for these reasons and other edge cases.
精彩评论