Brief Introduction of timestamp in DirectShow (zz)

Source: Internet
Author: User

Time Encoding

I. Concepts

Here we will describe an important concept in media stream processing-time encoding.

Time encoding is an auxiliary data for video and audio streams. It is included in video and audio files, which can be understood as a timestamp.

The SMPTE timecode is the sum of an SMPTE time and control code. It is a continuous digital address in a video or audio stream, a marker, and additional data. It is defined in ANSI/SMPTE12-1986. It aims to provide a video and audio address that can be processed by a computer.

The data structure of a maximum SMPTE time code is an 80-bit one-region, which contains the following content:

A. a timestamp in the format of HH: mm: SS: FF (hour: minute: Second: hour.

B and 8 4-bit binary data are usually called "User bit ".

C. Different flag Spaces

D. Synchronization Sequence

E. Validation and

This format is defined as timecode_sample in DirectShow.

A time code is divided into two forms. One is a linear time format LTC (vertical encoding). In a continuous time, each time code represents a sequence. Another time code is VitC (horizontal encoding), which stores two lines of the video signal in the vertical blanking interval, some of which are between 10 and 20.

The LTC time code is easy to add to a video, for example, because it is a separate audio signal encoding. However, it cannot be read when the drive is paused, slow, or fast forward. In addition, it may lose a channel of audio signal in non-professional video recorders.

The VitC time code is different from LTC. It can be read at a speed of 0 to 15 times. It can also be read from the video capture card. However, if you want to be recorded on a tape, you may need some other devices, which are usually expensive.

SMPTE time codes support two modes at the same time, one is non-lost mode and the other is lost mode. In the non-lost refer mode, the time code is recorded continuously increasing. It can play up to 30 Gb/s or higher.

The NTSC video playback standard is 29.97 Gb/s/second, which is due to the compatibility of the monochrome TV system. This leads to a question. In non-out-of-service mode, 108 of the hour is not synchronized, that is, when the real time is one hour, the time code is read-only 00: 59: 56: 12. Some problems may occur when you calculate the streaming media playback time. In order to solve this problem, we can skip the commit implementation if we can tolerate it. This method is implemented by skipping Two hops at the beginning of the count every minute, but not jumping between, and 50 minutes. Using this scheme, our network test results have an error of less than one hour, and the error of every 24 hours is about 3 hours.

In our actual work, although both modes are provided at the same time, the loss mode is usually adopted by us.

Ii. Typical use of time codes

Controlling peripheral devices for video capture and editing is a typical application. Such applications need to identify each clip of the video and audio streams. the SMPTE time code is used. The linear editing system usually controls three or more tape machines, and tries to switch the video between the disc recorders as much as possible. The computer must execute commands precisely, so it must obtain the address of the video tape at a specific time. There are many methods for applications to use time codes, mainly including the following:

A. Tracking video and audio sources throughout the editing process

B. Synchronize video and audio.

C. Synchronize multiple devices

D. Use undefined bytes in the time code, called userbits. This usually contains the date, ASCII code, or industry information of the movie.

3. Capture Time Codes

Generally, time codes are generated by capturing card devices with the ability to generate time codes. For example, a RS-422 requires a time code to control the peripheral and host communication.

After the time is generated, we need to obtain the time code from the video and audio in the stream format, which can be accessed later. Then we can process the time code in the following two steps:

A. Create a non-consecutive index at each shard location, and match the time code with each shard one by one. This list is written at the end of the file after the capture is complete. The list can be a matrix array similar to the following structure. For the sake of conciseness, only the directshowtimecode_sample structure is simplified.

struct {
DWORD dwoffset; // offset position in the cursor
Char [11] sztc; // The time code value in the Offset Value
// Hh: mm: SS: FF the format of HH: mm: SS; FF is the format of out-of-band.
} TIMECODE;

For example, here we can provide a time code in the video capture stream:

         {0, 02:00:00:02},
{16305, 15: 21: 13: 29} // time format in the 16305 hour

When this table is used, the time codes of any workers are well calculated.

B. Another approach is to write the time code as video and audio data. We do not recommend this method, so we will not introduce it.

You can edit, compose, and synchronize the files written with the time code. The time code is enough for us to understand. Many others are about standards. For more information, see.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.