I am currently developing an Android application that streams live video to a server using the libstreaming package. I am able to send the data to my laptop UDP socket, which has a type of an array of bytes. Now, I want to check if the bytes are correct and transform them into a video file. However, I do not understand how to do this. I tried to stream to an .h264 file and load it to internet resources for transforming h264 to the video. But the file had an incorrect format.
Here is the code snippet I'm using:
try (FileOutputStream outputStream = new FileOutputStream("output.h264")) {
DpReceive = new DatagramPacket(receive, receive.length);
serverSocket.receive(DpReceive);
outputStream.write(DpReceive.getData());
outputStream.close();
}
Bytes looks like this
What am I doing wrong? How can I achieve my goal? Thank you in advance.
is a one-second sample from an 'Inside Java' episode as h264 (base64-encoded) Saved as 'x.h264' (after decoding with base64),
file
says:Its header (first 16 bytes):