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 |