0

I Have converted the mp4 file to byte array or (stream), Now i want to convert that byte array or (stream) to Mp4 file, i have searched in web regarding this concept but my problem not yet solved please give me guidence.

This is my code i have stream and byte[], i want to convert to mp4 file NetworkStream stream = client.GetStream(); int i; i = stream.Read(bytes, 0, bytes.Length);File.WriteAllBytes(@"C:\Foo.mp4", bytes);

5
  • By coding, what have you tried? Commented May 26, 2015 at 11:02
  • 1
    File.WriteAllBytes("Foo.mp4", bytes) Commented May 26, 2015 at 11:02
  • if it is a byte array, then surely you can use new FileStream() and write it to disk... Commented May 26, 2015 at 11:02
  • If you "converted" an existing mp4 file to a byte array, and now want a way to write the byte array out to an mp4 file, what did this program really do? Just make a copy of an existing file? What's in the byte array? The complete mp4 file or only the digitized sound? Commented May 26, 2015 at 11:10
  • Thanks for quick response , i solved my problem with FileStream(); @CallumLinington Commented May 26, 2015 at 12:17

1 Answer 1

3

There is nothing about it being MP4 or anything else, if it's a byte array you can save it to the file by using File.WriteAllBytes as such

 File.WriteAllBytes(myfilepath,mybytearray);
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks you for your response, i have used same thing, it is creating file with only 2 kb data it is not playing. my actual file size is 290kb
Then the issue is with your data not with how you're saving it. If it saves 2kb it's because your byte array is 2kb in size. It's impossible to know where you went wrong without seeing your code
NetworkStream stream = client.GetStream(); int i; i = stream.Read(bytes, 0, bytes.Length); File.WriteAllBytes(@"C:\Foo.mp4", bytes);
Don't give us small bits, show us the whole function and not in a comment but in your question. If you want help we need some context and just those few lines don't help
And read on how to post code in stackoverflow to make it readable too, it's explained clearly when you edit your question
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.