Commit fb3603b4 by xiongziliang

兼容一些不规范的流

parent 56f044f8
......@@ -15,7 +15,10 @@ using namespace toolkit;
namespace mediakit{
static bool getAVCInfo(const char * sps,size_t sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){
static bool getAVCInfo(const char *sps, size_t sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){
if (sps_len < 4) {
return false;
}
T_GetBitContext tGetBitBuf;
T_SPS tH264SpsInfo;
memset(&tGetBitBuf,0,sizeof(tGetBitBuf));
......@@ -157,7 +160,10 @@ void H264Track::inputFrame(const Frame::Ptr &frame) {
}
void H264Track::onReady(){
getAVCInfo(_sps,_width,_height,_fps);
if (!getAVCInfo(_sps, _width, _height, _fps)) {
_sps.clear();
_pps.clear();
}
}
Track::Ptr H264Track::clone() {
......
......@@ -221,6 +221,10 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
}
void H264RtmpEncoder::makeVideoConfigPkt() {
if (_sps.size() < 4) {
WarnL << "sps长度不足4字节";
return;
}
int8_t flags = FLV_CODEC_H264;
flags |= (FLV_KEY_FRAME << 4);
bool is_config = true;
......
......@@ -186,7 +186,11 @@ void H265Track::inputFrame_l(const Frame::Ptr &frame) {
}
void H265Track::onReady() {
getHEVCInfo(_vps, _sps, _width, _height, _fps);
if (!getHEVCInfo(_vps, _sps, _width, _height, _fps)) {
_vps.clear();
_sps.clear();
_pps.clear();
}
}
Track::Ptr H265Track::clone() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论