Click here to Skip to main content
14,210,491 members
Rate this:
Please Sign up or sign in to vote.
Could you kindly help me? I want to convert a media file (image/audio/video) to an array of bytes and vice verse. I made the image converter but still the video and audio .. the idea of that is .. to send the media file as zeros and ones then reconvert it to original file.

Thanks in advance.
Updated 1-Apr-11 10:57am
Rate this:
Please Sign up or sign in to vote.

Solution 1

All files stored on a computer are binary. So I think that you might need to edit your question to make it clearer what it is that you want to do.
Hisham Ghatasheh 1-Apr-11 11:44am
I'm sorry for that .. I mean zeros and ones
Henry Minute 1-Apr-11 12:12pm
That's what binary is - zeros and ones.

It is still not clear what you are trying to actually do.

Are you trying to write the binary values out to a file as text like "0001110101011010110"?

Or something else?
Henry, you're already demonstrated angelic patience.
I cannot even post my usual learning+RTFM set of instruction. At certain level of confusion, even learning won't help becuase can be misused to create futher confusions. Any ideas? :-)
Hisham Ghatasheh 1-Apr-11 16:49pm
I'm now working on my own protocol the first step is to convert the media file to array of bytes and send it .. and the receiver should reconvert it from array of bytes to Audio/Video file..

I hope its clear now, and I'm so sorry for the weakness in my language !!!

Thank you
Henry Minute 1-Apr-11 16:57pm
All you have to do is send the array of bytes. They're already binary. :)
Hisham Ghatasheh 1-Apr-11 17:03pm
here is the problem .. how to make the array of bytes? .. how to convert the media file? there is a package support that?
Henry Minute 1-Apr-11 17:13pm
I all depends on how you propose to send the data. Unless you intend to do some special processing on the media file you are better off just zipping it and sending it
Hisham Ghatasheh 1-Apr-11 17:17pm
Aha .. I got your idea .. but my project requires to convert the file to binary
Henry Minute 1-Apr-11 17:25pm
As I said before if it's a file, it's already binary, so you are going to have to give more detail about your project.

Any time you start to read your file into memory prior to transmission, you are converting it to an array of bytes in memory.
Hisham Ghatasheh 1-Apr-11 17:27pm
just i want to take a video/audio file the convert it to binary (0111111111100010001) .. after that I want to reconvert it from binary (0111111111100010001) to video/audio file
fjdiewornncalwe 1-Apr-11 17:31pm
Why does this smell of an April Fool's Day Joke.
Henry Minute 1-Apr-11 17:40pm
You could be right.
Hisham Ghatasheh 2-Apr-11 4:37am
Sure its not
Jitesh Gosar 13-Jun-16 8:48am
I didn't get it. How can I see a video file in binary format?

If I open a video file(for example .mp4) in gedit,then I get some Hex and some random characters(that are not included in English alphabtes.
Please Explain.
Rate this:
Please Sign up or sign in to vote.

Solution 2

Take a look at this:

MSDN Magazine[^]
Hisham Ghatasheh 1-Apr-11 17:06pm
Thank you ! .. I will try it ..
Rate this:
Please Sign up or sign in to vote.

Solution 3

Dim sql As String = "INSERT INTO student VALUES(@Photo)"
Dim cmd As New SqlCommand(Sql, con)
Dim ms As New MemoryStream()
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
Dim data As Byte() = ms.GetBuffer()
Dim p As New SqlParameter("@photo", SqlDbType.Image)
p.Value = data
MessageBox.Show("record has been saved", "Save", MessageBoxButtons.OK)

i will searching too for the video converting to byte. but i have one of the solution you want to know. it only on the image file. you will set your data type to "image".

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

Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190618.1 | Last Updated 28 May 2012
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100