Configure the H.264 Encoder for Streaming

Streaming video needs to be below the sustained average bit rate supported by the network connection. In addition, the network connection may be able to achieve a higher peak bit rate for short periods of time. If these bit rates are  exceeded for long periods of time, packets can be dropped, or delayed if throttling is used to avoid exceeding the maximum bit rate. If packets are dropped, the video will show corrupted packets at the receiving end. If throttling is used, the packets will arrive later and later at the remote end, causing jittery playback. Even when the content is stored on a device, there can be a peak bit rate imposed by the speed of the hard disk or the memory. This is why sometimes you will see something like "XX phone will play video with a bitrate less than X Kbps". In this case, you should set the Maximum Bit Rate to X (or, even better, to 0.9 * X). 

To achieve smooth playback, the remote end will typically buffer some amount of data before starting playback. The buffering amount has to be greater than the time it takes to transmit the biggest frame of the video (usually the I frame). The amount of data you are buffering is also called the latency, because the video being played back will be behind the live video by this buffering amount. 

When you use the LEAD MPEG2 Transport Demultiplexer to play back the receiving video, specify the amount of buffering/latency by setting the ILMMpgDmx.CurrentStreamTime to -X, where X is the latency or buffering amount in seconds.

The   LEAD H264 Encoder (4.0) has several settings for generating fixed bitrate video. These settings are:

  1. ILMH264Encoder.BitRate = Bit rate = desired sustained average target bit rate

  2. ILMH264Encoder.MaxBitRate = Maximum Bit rate = desired maximum (peak) allowable bitrate

  3. ILMH264Encoder.MaxFrameDuration = Maximum Frame Duration = maximum allowable size for one frame (usually, the I frame) in ms

If you use the ILMH264Encoder Interface, the bit rate values are in bits per second (bps).

If you use the LEAD H264 Encoder property page, the bit rate values are in Kilo bits per second (Kbps). Please note these values are kilo bits/second, not kilo bytes per second. 

The Maximum Frame duration is using the Bit rate value (not the Maximum Bit rate). For example, if you generate video at 8Mbps and you specify a maximum frame duration of 250ms, then you are indicating no frame should be bigger than 2,000,000 bits = 250,000 bytes = 250KB. 

The Maximum Frame Duration has a big impact on the resulting video. Quite often, the I frame is as big as all the other frames in the GOP put together. This means that for a GOP that has a duration of 500ms (15 frames in a 30fps video), it is very likely the I frame will take 250ms to transmit at the normal bitrate. This means that when you play the video at the receiving end, you should specify a playback latency of at least 300 ms for a MPEG2 Transport stream:

ILMMpgDmx.CurrentStreamTime = - 0.3 

If you specify a Maximum Frame duration that is too low, the resulting video can be of a lower quality and lower bitrate than you might expect. Never set the maximum frame duration below the time per frame. For example, a 30fps video has a time per frame of 33ms. This means you should not set ILMH264Encoder.MaxFrameDuration below 33. 

Set the Maximum Bit Rate setting below the peak bitrate supported by the media or the network to avoid dropped packets. For example, if you will send the data over a network that can transmit data up to 8Mbits/sec, you should set the Maximum Bit Rate to a value below that (for example 7.5 Mbps).

Special values for these settings:

Help Version 20.0.2020.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Filters C API Help