将视频流保存到数据库的表中

时间:2020-12-19 16:58:31

I want to save a stream video into my database, I want to know what data type in SQL-Server is suitable to save video stream ?

我想将流视频保存到我的数据库中,我想知道SQL-Server中哪种数据类型适合保存视频流?

EDIT : Note that, I'm using EF4 as my project ORM.

编辑:请注意,我使用EF4作为我的项目ORM。

Any advice will be graceful.

任何建议都会很优雅。

Thanks.

3 个解决方案

#1


1  

For storing BLOBs such as video data you can use the varbinary(MAX) data type in SQL Server 2005 which is supported by Entity Framework.

对于存储视频数据等BLOB,您可以在实体框架支持的SQL Server 2005中使用varbinary(MAX)数据类型。

Keep in mind whenever you load the entity that contains this column EF will try to fully load your full video into memory, there is no byte streaming mode in EF - this means not only will this not scale well but with multiple users also becomes infeasible because of the memory requirements and will perform poorly. Don't do this - I would look hard for better alternatives.

请记住,无论何时加载包含此列的实体,EF都会尝试将完整视频完全加载到内存中,EF中没有字节流模式 - 这意味着这不仅不能很好地扩展,而且多个用户也变得不可行,因为的内存要求,并将表现不佳。不要这样做 - 我会努力寻找更好的选择。

#2


1  

we can assume that a video is basically a file and you can use the FILESTREAM SQL 2008 data type.

我们可以假设视频基本上是一个文件,您可以使用FILESTREAM SQL 2008数据类型。

there should be plenty of examples around, I found this:

应该有很多例子,我发现了这个:

http://weblogs.asp.net/aghausman/archive/2009/03/16/saving-and-retrieving-file-using-filestream-sql-server-2008.aspx

#3


1  

Download and Upload images from SQL Server via ASP.Net MVC. The article shows how to use streaming semantics for large BLOBs (avoid creating an in memory byte[]) and you ca use the implementation in C# forms just as well, is nothing specific for ASP MVC or web in general.

通过ASP.Net MVC从SQL Server下载和上载图像。本文展示了如何对大型BLOB使用流语义(避免在内存中创建byte []),并且您也可以使用C#表单中的实现,这对于ASP MVC或Web来说并不是特定的。

#1


1  

For storing BLOBs such as video data you can use the varbinary(MAX) data type in SQL Server 2005 which is supported by Entity Framework.

对于存储视频数据等BLOB,您可以在实体框架支持的SQL Server 2005中使用varbinary(MAX)数据类型。

Keep in mind whenever you load the entity that contains this column EF will try to fully load your full video into memory, there is no byte streaming mode in EF - this means not only will this not scale well but with multiple users also becomes infeasible because of the memory requirements and will perform poorly. Don't do this - I would look hard for better alternatives.

请记住,无论何时加载包含此列的实体,EF都会尝试将完整视频完全加载到内存中,EF中没有字节流模式 - 这意味着这不仅不能很好地扩展,而且多个用户也变得不可行,因为的内存要求,并将表现不佳。不要这样做 - 我会努力寻找更好的选择。

#2


1  

we can assume that a video is basically a file and you can use the FILESTREAM SQL 2008 data type.

我们可以假设视频基本上是一个文件,您可以使用FILESTREAM SQL 2008数据类型。

there should be plenty of examples around, I found this:

应该有很多例子,我发现了这个:

http://weblogs.asp.net/aghausman/archive/2009/03/16/saving-and-retrieving-file-using-filestream-sql-server-2008.aspx

#3


1  

Download and Upload images from SQL Server via ASP.Net MVC. The article shows how to use streaming semantics for large BLOBs (avoid creating an in memory byte[]) and you ca use the implementation in C# forms just as well, is nothing specific for ASP MVC or web in general.

通过ASP.Net MVC从SQL Server下载和上载图像。本文展示了如何对大型BLOB使用流语义(避免在内存中创建byte []),并且您也可以使用C#表单中的实现,这对于ASP MVC或Web来说并不是特定的。