手动计算 emgu 视频大小

Compute emgu video size manually

我正在使用 emgu 来保存未压缩的视频。 VideoWriter("video.avi", 0, (int)FrameRate, frameSize, true); 0 值表示保存的视频将被解压,参见 here。此外,FrameRate aws 设置为 30。 存储的Mat个文件是:var mat = new Mat(480, 640, Emgu.CV.CvEnum.DepthType.Cv8U, 3)。对于 13994 帧的存储视频,属性 window 表示:9.29 GB (6,449,164,288 bytes)(windows)。现在我正在尝试手动验证视频大小:

640*480*3*13994= 12,896,870,400 bytes,是 window 属性 returns 的两倍。

你能解释一下吗?

MediaInfo信息:

General
Complete name                            : name.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
Format profile                           : OpenDML
File size                                : 6.01 GiB
Duration                                 : 7 min 46 s
Overall bit rate                         : 111 Mb/s
Writing application                      : Lavf56.36.100

Video
ID                                       : 0
Format                                   : YUV
Codec ID                                 : I420
Codec ID/Info                            : 8 bit Y plane followed by 8 bit 2x2 subsampled U and V planes.
Duration                                 : 7 min 46 s
Bit rate                                 : 111 Mb/s
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate                               : 30.000 FPS
Compression mode                         : Lossless
Bits/(Pixel*Frame)                       : 12.000
Stream size                              : 6.01 GiB (100%)

谢谢。

今晚晚些时候我会仔细研究它,但现在你能确认 emgu 是否每帧使用 4 个字节(32 位整数),即使你的像素类型是 24 位 RGB ?

Formula = Width * Height * 3 (rgb) * 21658 (frames) * 4 (ie: 32bit Int) / 8 (bits per byte)

使用上面的公式我可以得到一个接近的数字...

640 * 480 * 3 * 13994 * 4 / 8 = 6,448,435,200

结果:

on disk size    : 6 449 164 288 bytes (Windows) 
calculated size : 6 448 435 200 bytes (Formula) 
remainder size  :       729 088 bytes (possible AVI Header size as bytes?)

暂时只是一个快速的,因为我不想涉及 bit-rate 等。通常 file-size 给出 bit-rate 或 vice-versa。但是根据您的估计,在制作文件之前您不会知道实际的 bit-rate 所以以上是我最好的猜测,直到我能正确考虑它...

PS:MediaInfo 可以向您显示 header 大小(以字节为单位)以确认最后 剩余大小 数量。