Microsoft DirectX 8.1 (C++)

Capturing Timecode

Timecode can be generated either by an external timecode generator, by a capture card capable of generating timecode, by the device control filter itself, or by an external device such as a VCR that has a built-in timecode reader. An RS-422 connection is generally necessary if an external device sends the timecode to the host.

After timecode is generated, it needs to be captured either in tabular or stream format concurrently with the video or audio, so that it can later be accessed during editing. This is handled in one of two ways:

1. Build a table that lists the timecode discontinuities indexed to frame position within the stream, and write the table to the end of the file after capture is complete. The list might be an array of structures that look like this (note that the following structure is a simplification of the DirectShow TIMECODE_SAMPLE structure and is intended as an example only):

struct {
    DWORD dwOffset; // Offset into stream in frames
    char[11] szTC;  // Timecode value at offset
                    // hh:mm:ss:ff for nondrop, hh:mm:ss;ff for drop frame
} TIMECODE;

For example, given a captured video stream with one timecode break in it, the list might look like this:

{0, 02:00:00:02},
{16305, 15:21:13:29}        // Timecode jumps at frame 16305.

Using this table, any frame's timecode can be easily calculated.

2. Treat the data as a stream and write it to the file just as video and audio are written. This is useful for rapidly changing data or even non-timecode data in the vertical blanking interval (VBI) such as closed-captioned data.

After the timecode data is properly stored with its associated frame data, applications that edit, composite, synchronize, or trigger can access and use a familiar and standard indexing system.