将视频转换为字节数组 [英] Convert video to byt array

查看:547
本文介绍了将视频转换为字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有



请将视频文件(AVI-MP4)转换为字节数组,我有路径

什么是最好的方式

这是我使用但是当文件大的时候给我内存错误

请如何转换它

Dear all

Please i want to convert video file (AVI - MP4) to byte array and i have the path
what is the best way
this is i used but when file large give me memory error
please how to convert it

videobytes=   File.ReadAllBytes(filepath);

推荐答案

文件大并没有告诉我们多少:我看过几个视频文件巨型到接近一个太字节!



但是......问题几乎肯定无法解决。如果您的视频文件超过2GB,那么您无法在.NET中将其作为单个数组加载 - 没有单个对象(并且字节数组是单个对象,因为字节是值类型,而不是引用)可能超过在任何情况下都是2GB。



因此你必须使用流加载它:你无法将整个文件读入内存。
"File large" doesn't tell us much: I've seen video files ranging from a couple of mega to nearly a terrabyte!

But...the problem is almost certainly unsolvable. If your video file exceeds 2GB, then there is nothing you can do in .NET to load it as a single array - no single object (and an array of bytes is a single object because byte is a value type, not reference) can exceed 2GB under any circumstances.

So you will have to load it in chunks using a stream: you can't read the whole file into memory.


这篇关于将视频转换为字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆