MJPEG 与 MPEG-4 编码时间
我正在测试智能相机的编码性能(MPEG-4 和 MJPEG)。我用 OpenCV/FFMPEG 编写了一个用于执行编码的应用程序,该应用程序从相机捕获图像并将其编码为所需的编码格式。在基准测试中,我发现 MJPEG 编码比 MPEG-4 编码花费的时间要长得多。我预计情况会是相反的。将单个帧编码为 MPEG-4 大约需要 31 毫秒,而编码为 MJPEG 大约需要 80 毫秒。与 MPEG-4 相比,MJPEG 真的需要这么长的时间吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MJPeg 理论上更快,主要是因为没有帧间压缩。
然而,有一些方法可以使 MPEG-4 更快。以下是需要考虑的几个因素:
MPEG-4 实际上可以是两种不同的格式,“第 2 部分”或“第 2 部分”
“第 10 部分”,第 2 部分要快得多。请参阅此处了解详细信息:
http://en.wikipedia.org/wiki/MPEG-4_Part_2。
编码器的设置可以产生一个数量级
不同之处。给定格式的快速设置可以是 10 倍或更多
比具有较慢设置的相同格式更快(速度/质量
权衡)。
MPEG-4 的编码器是最优化的代码片段之一
在这个星球上。他们仍然大量使用汇编语言。他们可以
在实践中很容易比其他不重的格式更快
优化。
如果您的 IO 速度较慢(网络、硬盘驱动器),这可能会导致结果出现偏差。
例如,不压缩是最快的,对吗?但这需要
写入较大文件的时间。
因此,在实践中,由于这些原因和其他边缘情况,MJPEG 可能会变慢。
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.