1

How can I convert a byte array to a video file? like mp4 Given the following code

dbConnection connection=new dbConnection(getApplicationContext());
                    SQLiteDatabase db=connection.getReadableDatabase();
                    unhideCursor=db.query(dbConnection.TABLE_VIDEOS, new String[]{dbConnection.VIDEO_DATA}, dbConnection.VIDEO_TITLE+"=?", new String[]{videoTitle}, null, null,null);
                    byte[]videoData=unhideCursor.getBlob(unhideCursor.getColumnIndex(dbConnection.VIDEO_DATA));

1 Answer 1

4

If the byte array is already a video stream, simply serialize it to the disk with the extension mp4. (If it's an MP4 encoded stream).

Java

FileOutputStream out = new FileOutputStream("video.mp4");
out.write(videoData);
out.close();

C#

Stream t = new FileStream("video.mp4", FileMode.Create);
BinaryWriter b = new BinaryWriter(t);
b.Write(videoData);
t.Close();

Hope this helps!

Jeffrey Kevin Pry

Sign up to request clarification or add additional context in comments.

Comments

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.