1

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();
}
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
user2666952
  • 21
  • 1
  • 7

3 Answers3

1

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:

Thumbnail video C#

Community
  • 1
  • 1
Ashigore
  • 4,618
  • 1
  • 19
  • 39
0

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.

Ehsan
  • 31,833
  • 6
  • 56
  • 65
  • Yes I need to get all images/Frames,Can you please tell me how can i get that – user2666952 Aug 28 '13 at 07:13
  • why do you need that? if you need all images/frames then it is equivalent to a video file. and 1 min video may contain thousands of images. What do you want to achieve? – Ehsan Aug 28 '13 at 07:26
  • Actually from that video I need to get all images and from those images I need to match with other images, – user2666952 Aug 28 '13 at 07:34
  • why don't you do video comparison directly? – Ehsan Aug 28 '13 at 07:35
  • Also i need to get those images only that have face ,I have one software from where i can achieve that but i am not sure how can i get images in bytes – user2666952 Aug 28 '13 at 07:36
  • so you need face recognition as well. – Ehsan Aug 28 '13 at 07:38
  • Yes right i need face recognition as well,but I have software from where i can achieve this – user2666952 Aug 28 '13 at 07:39
  • you need a complete software and your question states that you only need to convert image to bytes:) – Ehsan Aug 28 '13 at 07:41
  • no i need images in byte format only from video ,face matching functionality I have already built and it is working fine.I just need to pass array of byte to that function and that will match images automatically – user2666952 Aug 28 '13 at 07:43
  • Do you have any idea about it – user2666952 Aug 28 '13 at 07:56
  • it is 2 broad to be answered. break down your tasks in small chunks and then try to find answers. i have already answered what steps you need to do. – Ehsan Aug 28 '13 at 07:57
0

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.

Dominic Sore
  • 397
  • 2
  • 4
  • 14
  • i just want bytes of images from Video,Is that possible to do that – user2666952 Aug 28 '13 at 07:26
  • Not impossible. However, impractical. You will need to do a lot of research. I personally do not have a definitive solution for you. Read up on byte streams and video file headers as a starter. Other than that I cannot help. Sorry. – Dominic Sore Aug 28 '13 at 07:48