forked from mutaphore/RTSP-Client-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VideoStream.java
39 lines (30 loc) · 1007 Bytes
/
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
39
//VideoStream
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);
return(fis.read(frame,0,length));
}
}