Reputation: 21
I am trying to get the images in bytes from Video in c#.I am uploading the video file and from that video file we need to get images in byte format so that I can separate byte for each image and I can match the byte with other images.
Kindly give me some suggestion how can i do this.
Now I am doing this but getting byte of all video ,i am not sure how can i get the byte of images in video.
byte[] byt = null;
using (Stream s = file.InputStream)
{
MemoryStream ms = s as MemoryStream;
if (ms == null) ms = new MemoryStream();
s.CopyTo(ms);
byt = ms.ToArray();
}
Upvotes: 1
Views: 1865
Reputation: 385
Various file formats will require different techniques to achieve what you're looking for.
For example, MPEG. One of the most widely used video files. First you will have to find a way to decode the video information. They use the discrete cosine transform method (DCT). Then you will have to decompress the the video file as the compressed file only stores the changes of frames as opposed to the frames themselves. Only then can you get the data you need. Even then they use lossy compression, so the final image you will receive will not be of great quality.
All of that just for one file type. You then have to figure out all of the other file types you wish to use.
Short answer, try find a different solution.
Upvotes: 0
Reputation: 4678
Videos do not contain images in the conventional sense so the short answer is that you can't. If what you want to do is generate a thumbnail from a video, see here for an example solution:
Upvotes: 1
Reputation: 32729
Kindly give me some suggestion how can i do this.
First of all what you should know is what image you want to get? do you want to get all images/frames? It is not as simple as it may seem to you.
And for different formats, you may have to use different techniques for getting the specific image. First read that.
Upvotes: 0