Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to store & retrieve video from SQL database. That video has to be play in vlc or windows media player with the help of C# coding.Tell me the solution....

What I have tried:

I tried with flow player......
Posted
Updated 24-Nov-16 22:41pm

Seriously? Don't do it.
The problem is that video files are big - and get very big, very quickly. When you write code to retrieve them from a DB and stream them to VLC or Media player, you are doubling the memory, the bandwidth, and everything else involved. Think about it: SQL Server has to retrieve the data into it's memory. It then feeds that to the network to pass to your application. Which allocates memory to store it, and passes it either to a third party app like VLC or to a (separate machine if this is an ASP.NET app that would be the client PC)
That's a huge amount of data being thrown around, and that uses resources like crazy - which means delays, buffering, and general nastiness.

A better solution is to store a path to the video file in the DB, and use that to access the actual video data. With luck, you can just pass the path to your movie player and it accesses the data or stream directly.
 
Share this answer
 
Comments
StackQ 25-Nov-16 4:41am    
Totally agree +5
 
Share this answer
 
Check filestream concept in sql server for BLOB.
 
Share this answer
 
C#
if (openFileDialog1.FileName != null)   
{
 v_Filepath = FilePath;
System.IO.FileStream fs = new System.IO.FileStream(FilePath, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite);
System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(fs);
long byteLength = new System.IO.FileInfo(FilePath).Length;
Attachmnt = binaryReader.ReadBytes((Int32)byteLength);  //This data u can save in table
fs.Close();
 fs.Dispose();
binaryReader.Close();
} 

//And to get it again from database 

string newName;
newName = saveFileDialog1.FileName;
File.WriteAllBytes(saveFileDialog1.FileName, objDoc.DocContent);
writeStream = new FileStream(saveFileDialog1.FileName, FileMode.Open);
BinaryWriter writeBinay = new BinaryWriter(writeStream);
writeBinay.Write(objDoc.DocContent);
writeBinay.Close();
writeStream.Close();


or check my Question link:-
how to save a byte[] code in pdf/rtf/xps/doc file.(Windows not asp)[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900