将字节数组转换为视频文件

时间:2011-07-14 12:43:24

标签: android video-streaming

如何将字节数组转换为视频文件?喜欢mp4 给出以下代码

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 个答案:

答案 0 :(得分:4)

如果字节数组已经是视频流,只需将其序列化为扩展名为mp4的磁盘即可。 (如果是MP4编码的流)。

爪哇

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();

希望这有帮助!

Jeffrey Kevin Pry