视频长宽的获得

一、ABLMediaServer

bool CMediaStreamSource::PushVideo(unsigned char* szVideo, int nLength, char* szVideoCodec)

                     |

                                                                           |

    GetVideoWidthHeight(m_mediaCodecInfo.szVideoName,szVideo, nLength);

                                                                           |

                                                                           |

GetWidthHeightFromSPS(pVideoData + nPos, nDataLength - nPos, nWidth, nHeight);

                                                                           |

                                                                          |

int   CSPSReader::Do_Read_SPS( bs_t *s, int *width, int *height)

1.关键结构
typedef struct tag_bs_s
{
uint8_t *p_start;
uint8_t *p;
uint8_t *p_end;

int i_left; // i_count number of available bits
int i_bits_encoded; // RD only
} bs_t;

2._bs_read( s, 1 );读取指定位数

3._bs_read_ue;读取无符号一个字节

4._bs_read_se读取有符号一个字节

 二、ZLMediaKit

 static bool getAVCInfo(const char *sps, size_t sps_len, int &iVideoWidth, int &iVideoHeight, float &iVideoFps)

1.h264DecSeqParameterSet((void *)&tGetBitBuf, &tH264SpsInfo)

(1) T_GetBitContext tGetBitBuf输入的结构。

(2)T_SPS tH264SpsInfo输入的结构,得到sps的信息

2.h264GetWidthHeight(&tH264SpsInfo, &iVideoWidth, &iVideoHeight);

从T_SPS tH264SpsInfo的结构中得到宽和高。

3. h264GeFramerate(&tH264SpsInfo, &iVideoFps);

从T_SPS tH264SpsInfo的结构中得每秒播放的帧数。

=========================================================================================================================================================================

 涉及的整个数据为:共21个字节

{0x67, 0x4d, 0x0, 0x29, 0x8d, 0x8d, 0x40, 0x3c, 0x1, 0x13, 0xf2, 0xc2,
0x0, 0x0, 0xe, 0x10, 0x0, 0x2, 0xbf, 0x20, 0x8}

==========================================================================================================================================================================

 在int h264DecSeqParameterSet(void *pvBufSrc, T_SPS *ptSps)中,  通过 pvBuf = deEmulationPrevention(pvBufSrc);对数据进行转换以后。

1. getBits和getOneBit与_bs_read对应。

2.getBits没有返回值时与_bs_skip对应。

3.parseUe与_bs_read_ue对应。

4.parseSe与_bs_read_se对应。                   

posted @ 2022-11-25 15:38  泽良_小涛  阅读(109)  评论(0编辑  收藏  举报