视频长宽的获得
一、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对应。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!