I'm creating an application in which I need to read from a video file and transmit packets of data that can be read back into memory. I am using the Ogg video format because it is open source and because I found it simpler to understand. I used BufferedInputStream
to read from the file, but as the first 28 bytes are header information I opted to use the buffer.read(byte[])
method as follows:
byte[] buffer = new byte[28];
FileInputStream in = new FileInputStream("/path/video.ogv");
BufferedInputStream buffStream = new BufferedInputStream(in);
buffStream(buffer);
So, I can read a sequence of bytes faster. When I inspect the buffer
element in the eclipse debug, I noticed that values above 128 are negative, this I think is due to the fact that the maximum number that I can represent with 1 byte is 128. I know that the values are corrupted because when I open the file in the link , I can see the correct value in hexadecimal. For example, the value that corresponds to B5 = 181(dec)
is set to -75. How can I use this method and work around this data corruption?
Note: Using a video decoder that already does this transparently is not an option. It is necessary to be this way because I am developing a distributed application and the data packages will be destined for other computers.