当前位置:网站首页>Live555 push RTSP audio and video stream summary (III) flower screen problem caused by pushing H264 real-time stream
Live555 push RTSP audio and video stream summary (III) flower screen problem caused by pushing H264 real-time stream
2022-07-05 08:00:00 【Drink more hot water-】
live555 do RTSP Server When pushing real-time streams , The solution to the flower screen problem
There should be many places that can be optimized , At present, only 3 Strategy solutions :
Due to live555 The complex classes in the error are very unfamiliar , These are the conclusions after simple debugging :
1.StreamParser.cpp
As I understand it , This parameter represents a frame H264 The size of the data , Default 150K, If the resolution is large , It is likely to exceed the size , Maybe every frame will lose data and splash the screen ---------> But I just changed ; There is no actual change to large resolution verification
#define BANK_SIZE 800000 //300 -> 800
2. modify maxSize size
OutPacketBuffer::maxSize = 1000000; //
stay H264FramedLiveSource::doGetNextFrame() in , It's usually right H264 Do the operation of memory copy :
memcpy(fTo ,video_buf,fMaxSize);
fTo yes live555 Released pointer , The maximum memory it points to is maxSize , With every turn fTo Copy the data ,fMaxSize From maxSize Slowly decrease , until 0, Then point to another maxSize Size of memory
therefore What I see is : take maxSize The size is from 200k increase , You will find that the problem of flower screen has been improved , however , It will still spend dozens of seconds
3. utilize FrameSource Medium fNumTruncatedBytescans
And then the last one :, With every turn fTo Copy the data ,fMaxSize From maxSize Slowly decrease , until 0, Then point to another maxSize Size of memory , So in fTo Of buf When it is about to run out , The last frame H264 The data can't be put , Will put the data that can't be put , I threw it away manually , Then it's time to spend the screen ! Meow
that fNumTruncatedBytescans yes FrameSource One of the parameters in , It means the number of discarded bags , But in fact, direct operation of it has no effect . Only one number can be customized to implement my idea :
every time fTo When exhausted , Save the lost data locally , Next callback doGetNextFrame() when , First write in the lost data , Then write this time 264 Put the bag in the back .
because H264 Yes, there is NALU Of , There are strict head and tail marks ; So it seems OK Of
then ,live555 Of buf Not directly fTo the buf, Not this buf Only one frame of data can be saved , This is also the wrong idea before
Upper pseudo code :
void H264FramedLiveSource::doGetNextFrame()
{
int ret = 0;
int h264_total_size = 0;
int64_t timeStamp;
unsigned char video_buf[MAX_VDATA_SIZE];
memset(video_buf,0,sizeof(video_buf));
getH264Data(&h264_total_size,&timeStamp ,video_buf);
if(h264_total_size > fMaxSize) {
// buff Exhausted frames
memcpy(fTo ,video_buf,fMaxSize);
memcpy(truncatedBytes, video_buf+fMaxSize,h264_total_size-fMaxSize);
fNumTruncatedBytes = h264_total_size - fMaxSize;
NumTruncatedBytes = h264_total_size - fMaxSize;
fFrameSize = fMaxSize;
}
else
{
if(NumTruncatedBytes != 0)
{
memcpy(fTo ,truncatedBytes,NumTruncatedBytes);
memcpy(fTo+NumTruncatedBytes ,video_buf,h264_total_size);
fFrameSize = h264_total_size+NumTruncatedBytes;
fNumTruncatedBytes = 0;
NumTruncatedBytes = 0;
memset(truncatedBytes,0,sizeof(truncatedBytes));
}
else
{
memset(truncatedBytes,0,sizeof(truncatedBytes));
memcpy(fTo ,video_buf,h264_total_size);
fFrameSize = h264_total_size;
fNumTruncatedBytes = 0;
NumTruncatedBytes = 0;
}
}
FramedSource::afterGetting(this);
return;
}
边栏推荐
- Scm-05 basis of independent keyboard
- Cadence simulation encountered "input.scs": can not open input file change path problem
- Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine
- Reasons for rapid wear of conductive slip rings
- A complete set of indicators for the 10000 class clean room of electronic semiconductors
- Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
- Halcon's practice based on shape template matching [1]
- Screen record of the opening ceremony of the Beijing winter olympics 2
- Global and Chinese market of quenching furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
- Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
猜你喜欢
Carrier period, electrical speed, carrier period variation
万字详解八大排序 必读(代码+动图演示)
Altium designer 19.1.18 - hide the fly line of a network
After installing the new version of keil5 or upgrading the JLINK firmware, you will always be prompted about the firmware update
Software designer: 03 database system
Beijing Winter Olympics opening ceremony display equipment record 3
Shell脚本基本语法
Halcon's practice based on shape template matching [1]
Altium Designer 19.1.18 - 导入板框
研究发现,跨境电商客服系统都有这五点功能!
随机推荐
Shape template matching based on Halcon learning [9] PM_ multiple_ dxf_ models. Hdev routine -- [read and write XLD from DXF file]
Extern keyword function
Network communication model -- Network OSI tcp/ip layering
Altium Designer 19.1.18 - 导入板框
找不到实时聊天软件?给你推荐电商企业都在用的!
About yolov3, conduct map test directly
Shell script basic syntax
Baiwen 7-day smart home learning experience of Internet of things
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
C WinForm [realize the previous and next selection pictures] - practice 7
Pointnet++ classification practice
The browser cannot access Baidu
Threads and processes
Distinction between heap and stack
Global and Chinese market of rammers 2022-2028: Research Report on technology, participants, trends, market size and share
IEEE access personal contribution experience record
Global and Chinese markets for anesthesia, breathing and sleep apnea devices 2022-2028: Research Report on technology, participants, trends, market size and share
Interview catalogue
STM32 learning method
C WinForm [change the position of the form after running] - Practical Exercise 4