美文网首页
live555推送1080p花屏

live555推送1080p花屏

作者: 星夜兼程工作笔记 | 来源:发表于2019-10-13 21:02 被阅读0次

最近一直研究live555推送rtsp流到easydarwin,实现转发,但是遇到一个问题:live555推送之后的视频流出现花屏,在网上搜罗一大圈之后找到一个答案,就是live555内部OutPacketBuffer默认大小只有60000,即是unsigned OutPacketBuffer::maxSize = 60000;当我推送1080p视频流的时候,用vlc播放,出现部分视频是花的,主要就是缓冲区太小了,将这个值改大一点即可,目前测试改成288000,视频不会出现花屏,问题完美解决。

1、大数据帧花屏

live555推送之后的视频流出现花屏,查看源码DynamicRTSPServer.cpp文件,源码如下:

   sms->addSubsession(MPEG4VideoFileServerMediaSubsession::createNew(env, fileName, reuseSource));

  } else if (strcmp(extension, ".264") == 0) {

    // Assumed to be a H.264 Video Elementary Stream file:

    NEW_SMS("H.264 Video");

    OutPacketBuffer::maxSize = 100000; // allow for some possibly large H.264 frames

    sms->addSubsession(H264VideoFileServerMediaSubsession::createNew(env, fileName, reuseSource));

  } else if (strcmp(extension, ".265") == 0) {

    // Assumed to be a H.265 Video Elementary Stream file:

    NEW_SMS("H.265 Video");

    OutPacketBuffer::maxSize = 100000; // allow for some possibly large H.265 frames

    sms->addSubsession(H265VideoFileServerMediaSubsession::createNew(env, fileName, reuseSource));

  } else if (strcmp(extension, ".mp3") == 0) {

    // Assumed to be a MPEG-1 or 2 Audio file:

    NEW_SMS("MPEG-1 or 2 Audio")

查看上面红色部分对于H264和H265输出包最大缓冲100000字节(100K),对于高清视频缓冲区太小了,必需更改大些。目前更改到800000,对于1080P视频使用VLC播放时,不会再出现花屏。

2、循环播放文件

在liveMedia库下的ByteStreamFileSource.cpp文件中的95行,找到

void ByteStreamFileSource::doGetNextFrame() {

  if (feof(fFid) || ferror(fFid) || (fLimitNumBytesToStream && fNumBytesToStream == 0)) {

    handleClosure();

    return;

  }

更改为

void ByteStreamFileSource::doGetNextFrame() {

  if (feof(fFid) || ferror(fFid) || (fLimitNumBytesToStream && fNumBytesToStream == 0)) {

    //handleClosure();

    //return;

  fseek(fFid, 0, SEEK_SET);

  }

主要思想为,当文件读完后不让关闭文件,而是重新读取文件。经过测试,当VLC关闭RTSP链接后,文件会关闭,重新打开其他文件不受影响。

相关文章

网友评论

      本文标题:live555推送1080p花屏

      本文链接:https://www.haomeiwen.com/subject/zqvkmctx.html