0

I would like to know how to access the contents of the GOV headers of a mp4 video file.

I am using an Axis camera to stream video over RTSP, which is stored in the hard disk in mp4 format. According to the documentation, the camera inserts specific trigger data in the MPEG4 GOV header, but I don't know how this information can be accessed or retrieved.

I am developing a C++ application, but for now I don't need to process the data programmatically, so a solution that allows the visualization of the GOV header contents would be enough for me.

2 Answers2

0

The supplementary data is typically embedded right into stream and is supposedly written into video payload data of the MP4 file. The intention is to retain the entire stream MPEG-4 compliant, still have the additional data inside. Decoders would typically just ignore it.

You typically need to stream that data back from the file and parse the stream to extract the portions of data with trigger information. You would need specific APIs for video streaming (file format/demultiplexer etc - what is your OS and environment after all?) and you would need Axis technical information to see what exactly they are embedding and how exactly you need to parse that out.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • I am developing under Windows 7 using Visual C++ 2008 Express Edition. The documentation says that the trigger data block is included as "user data" in the GOV header, which may contain several data blocks following each other in this format. The user data section starts with 000001b2(hex) and the trigger data starts with 0a03(hex). – Juan Gómez Dec 21 '12 at 10:19
0

If you are streaming over RTSP, the MPEG4 header will not be transmitted - instead the "SDP" (session description protocol) information is exchanged via a DESCRIBE request from the client. This sdp file contains an encoded version of the frame rate etc. that is actually taken from the MDAT atom in the mpeg4 header.

If you specifically need to access the gov atom to determine the p-frame i-frame differential, you could try parsing the MPEG4 header on the server and transmitting it via a separate channel.

The way an MPEG4 header looks is basically a plaintext atom name, and then a length that is usually 4 bytes (you'll need to byte swap depending on your platform), and then data.

Here is some debugging code I have in my mpeg4 header parser:

public boolean valid_atom(byte[] word, int offset) {
    for (int i = 0; i < 4; i++)
        if (!(word[i + offset] >= 'a' && word[i + offset] <= 'z') && !(word[i + offset] >= 'A' && word[i + offset] <= 'Z'))
            return false;
    return true;
}

...

public int parse_atom(byte[] b, int offset, int depth) {
    int len;
    len = ifba(b, offset);
    Log.d(TAG, String.format("atom: %c%c%c%c depth %d @ %d len %d", b[offset + 4], b[offset + 5], b[offset + 6], b[offset + 7], depth, offset, len));
    return len;
}

...

private int ifba(byte[] buffer, int offset) {
    int retval = (buffer[offset] & 0xFF) << 24;
    retval += (buffer[offset + 1] & 0xFF) << 16;
    retval += (buffer[offset + 2] & 0XFF) << 8;
    retval += (buffer[offset + 3] & 0XFF);
    return retval;
}
floatingice
  • 179
  • 6