Summary of AS3 parsing FLV format and video problems

Source: Internet
Author: User
Tags format definition flv file

Why should I parse the FLV format?

In the live project encountered need to statistics Flash video frame interval length, first frame, GOP, and other key data, the inevitable need to parse the FLV file.

noun definition

First frame: Refers to the user to see the first video frame.
First frame length: Refers to the user to open the Web page to see the first video frame.
I frame: Video keyframe, contains all the graphic information.
P Frame: Video interval frame, is based on the P frame before the P-frame or I-frame diff out of the frame. The amount of data is smaller than I frame.
Gop:group of the picture (Image Group), which refers to the distance between two I frames
The FLV file format definition

FLV format definition: FLV is a container format, it supports the audio coding of linear PCM, ADPCM, MP3, Nellymoser, G711 a-law PCM, G711 Mu-law PCM, AAC, Speex, etc., supported video coding has H264, On2 VP6, Sorenson Spark and so on.

Using OSMF to parse FLV formats

Address: ps://sourceforge.net/adobe/osmf/home/home/">https://sourceforge.net/adobe/osmf/home/home/

The Org.osmf.net.httpstreaming.flv.FLVParser class using OSFM

var flvparse = new Flvparser ();
Flvparse.parse (Inbytes, True, function (Currenttag:flvtag): Boolean
{
Switch (currenttag.tagtype)
{
Case Flvtag.tag_type_video:
{
Video frames can be judged by Flvtagvideo Frametype to determine if I frame to compute GOP
Statistical frame interval
Break
}
Case Flvtag.tag_type_audio:
{
Audio Frames
Break
}
Default:
{
Script Frame
Break
}
}
return true;
});
Video playback Quality Control

Key data: First frame, drop frame rate, flashbuffer length of the first frame directly related to the user experience, it is best to do the second open. Drop frame rate can reflect the user watching video when the cotton situation. The flashbuffer length can reflect the user's delay condition to some extent.

After repeated tests, it is found that the buffertime increase will decrease the frame rate to some extent. But it will increase the length of flashbuffer, that is, increase the delay. It also increases the length of the first frame. At present, the Buffertime value of online classrooms is 1S.

Besides the frame, the current knowledge of the frame and buffertime, browser, FLV file video frame time stamp and so on have a certain relationship. Chrome frames are higher than IE in browsers. Video frame time stamp uniformity can reduce the drop frame.

Common problems in the live broadcast

[A sound has no picture]

Cause: The user must wait for an I frame to unlock when they enter. P frames need to refer to the front frame. Video live in the process of the user is randomly entered, then the user received the first frame may be a P-frame also may be I frame, if the user is just lucky to receive the first frame is I frame then he is the second open.

Solution: We said before that the user received the first frame is I frame then it is seconds open. How can I let the user receive the first frame is I frame it? There are two kinds of schemes

Cache I frames (or cache GOP):

The server caches all frames of the previous I frame to the user's entry time and throws them to the client at a time. At this point the client will open the client in order to reduce and source of delay, usually do accelerated playback. For example, Dou Fish, Ying is the use of this scheme.

Advantage: The technology implementation is relatively simple, can realize the second open.

Disadvantage: When the user frequent access to the room, will cause a large number of service-side bandwidth overhead.

Dynamic Encoding I frames:

The service side does not have a live video decoding in the process, dynamic coding.


Figure: Assuming our GOP is 5, the actual use is about 40 or higher (our GOP is probably 200 I'll talk nonsense) the server opens a separate code sequence for each p frame between I frame and P frame. The price is that when the GOP is 40, there will be 40 coded sequences.

Benefits: can save service-side bandwidth resources
Disadvantage: is to compare the consumption of CPU resources.

[There is no sound in the picture]

This possibility is relatively small, usually because there is no sound on the uplink.

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.