Live555 + FFMPEG how to extract key frames (I frame, P frame, B frame)

Source: Internet
Author: User

Live555 + FFMPEG how to extract key frames (I frame, P frame, B frame)
When developing a Streaming Media Player, especially on the Windows Mobile and Symbian (s60) platforms, you may need to develop your own player.
The s60 platform provides the cvideoplayutility interface to implement streaming media players. However, because it is not open-source, many operations are limited compared with self-developed players.
Live555 is mainly used for network stream receiving, while FFmpeg is used to encode/decode the received data. I frame, P frame, and B frame are three types of video streams. I frame is also a key frame.
It is a base frame. P frames are generally determined based on I frames, while B frames need the first two pieces of information.
For example:

The input sequence for Video Encoder
1 2 3 4 5 6 7
I B P B I

Let's take 1, 2, 3... as PTS for simplification

The out sequence for video encoder (this equals the decoder sequence)
1 4 2 3 7 5 6
I P B I B

The sequence of the player live555 received should be:

1 4 2 3 7 5 6

After decoder decoding, the order returns to the normal order of 1 2 3 4 5 6 7.

Therefore, we can determine the frame type based on avcodec_decode_video.
The order after avcodec_decode_video is certain. Strictly follow 1 2 3 4... In this order.
Method for Determining frames I, P, and B:
(1): If the decoding is successful, neither I frame nor P frame (based on avframe-> keyframe, determine whether it is an I frame ).
If it is not an I frame or P frame, it can only be B frame (determined by PTS ).
(2) avframe-> pict_type integrated PTS:
If (ff_ I _type = picture-> pict_type)
{
Printlog ("<II> ");
}
Else if (ff_p_type = picture-> pict_type)
{
Printlog ("<PP> ");
}
Else if (ff_ B _type = picture-> pict_type)
{
Printlog ("<BB> ");
}
Else if (ff_s_type = picture-> pict_type)
{
Printlog ("<SS> ");
}
Else
{
Printlog ("<othertype> ");
}
Normally, B frames are not printed, Because I frames or P frames are successfully decoded.

 

Source: http://www.zixundao.com/viewthread.php? Tid = 2814 & extra = & page = 1

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.