Click here to Skip to main content
11,803,019 members (58,290 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Video convert audio
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.
Posted 1-Apr-11 3:58am
Edited 1-Apr-11 10:57am
Rate this: bad
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.
hisam-gh at 1-Apr-11 11:44am
I'm sorry for that .. I mean zeros and ones
Henry Minute at 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?
SAKryukov at 1-Apr-11 12:16pm
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? :-)
hisam-gh at 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 at 1-Apr-11 16:57pm
All you have to do is send the array of bytes. They're already binary. :)
hisam-gh at 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 at 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
hisam-gh at 1-Apr-11 17:17pm
Aha .. I got your idea .. but my project requires to convert the file to binary
Henry Minute at 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.
hisam-gh at 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
Marcus Kramer at 1-Apr-11 17:31pm
Why does this smell of an April Fool's Day Joke.
Henry Minute at 1-Apr-11 17:40pm
You could be right.
hisam-gh at 2-Apr-11 4:37am
Sure its not
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Take a look at this:

MSDN Magazine[^]
hisam-gh at 1-Apr-11 17:06pm
Thank you ! .. I will try it ..
Rate this: bad
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)

  Print Answers RSS
0 OriginalGriff 335
1 KrunalRohit 291
2 F-ES Sitecore 270
3 CPallini 270
4 Sergey Alexandrovich Kryukov 234
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,735
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 28 May 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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