I have a Url and I have to download video from that url. My application is designed in such a way that I can access the video data as byte array only. I am getting the videoframes but only the last frame is get recorded.My code is given below.Anyone please help.
frameData = new byte[mContentLength];
skipBytes(headerLen);
readFully(frameData);
System.out.println("frameData "+frameData);
String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/req_videos");
myDir.mkdirs();
file = new File(myDir, "Sample.mp4");
FileOutputStream out = new FileOutputStream(file);
out.write(frameData);
//out.write(frameData, 0, frameData.length);
out.close();
Well, you can convert your byte array into an InputStream , like this:
InputStream input = new ByteArrayInputStream(yourByteArray);
Then you can loop through it and get your output file.
InputStream input = ...;
OutputStream output = output = new FileOutputStream("yourfilename");
byte data[] = new byte[4096];
int count;
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.