-
Notifications
You must be signed in to change notification settings - Fork 0
/
VideoStream.java
38 lines (30 loc) · 1.02 KB
/
VideoStream.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.io.*;
public class VideoStream {
FileInputStream fis; //video file
int frame_nb; //current frame nb
//-----------------------------------
// Constructor
//-----------------------------------
public VideoStream(String filename) throws Exception{
//Init variables
fis = new FileInputStream(filename);
frame_nb = 0;
}
//-----------------------------------
// Getnextframe
// Returns the next frame as an array of byte and the size of the frame
//-----------------------------------
public int getnextframe(byte[] frame) throws Exception
{
int length = 0;
String length_string;
byte[] frame_length = new byte[5];
//Read current frame length
fis.read(frame_length,0,5);
//Transform frame_length to integer
length_string = new String(frame_length);
length = Integer.parseInt(length_string);
System.out.println("Frame "+frame_length);
return(fis.read(frame,0,length));
}
}