Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache H264 GOPs in order to allow readers to decode frames immediately #1209

Open
aler9 opened this issue Oct 28, 2022 · 7 comments · May be fixed by #4189
Open

Cache H264 GOPs in order to allow readers to decode frames immediately #1209

aler9 opened this issue Oct 28, 2022 · 7 comments · May be fixed by #4189
Labels
enhancement New feature or request general

Comments

@aler9
Copy link
Member

aler9 commented Oct 28, 2022

Describe the feature

Discussed here #1132

NOTE: this feature is already present in HLS. It is missing in WebRTC, SRT, RTSP, RTMP.

@aler9 aler9 added the enhancement New feature or request label Oct 28, 2022
@aler9 aler9 changed the title Cache H264 GOPs in order to allow readers to receive frames immediately Cache H264 GOPs in order to allow readers to decode frames immediately Oct 28, 2022
@aler9 aler9 added the general label Apr 17, 2023
@sourcez
Copy link

sourcez commented Jun 14, 2023

This would be a very desired feature for the video platform we are currently building. Any outlook on when this could be build in? Thanks !

@jordybsecurite
Copy link

Can you maybe give some pointers as to what you think is necessary to implement this (e.g. which files to edit)? Maybe I can give it a go

@aler9
Copy link
Member Author

aler9 commented Jul 11, 2023

Hello, in my opinion to implement this you can hack formatprocessor.H264, which is an object that is initialized once for every H264 track of every stream:

https://github.com/bluenviron/mediamtx/blob/main/internal/formatprocessor/h264.go

In this structure you have to save all NALUs in a buffer until a key frame is received; when a key frame is received, this buffer must be emptied, and filled with new NALUs starting from the key frame.

When a new RTSP, RTMP of WebRTC client connects (not HLS, since key frame caching is already present in HLS), you have to send to this client all NALUs that are present in the buffer.

@0x5e
Copy link

0x5e commented Jul 18, 2023

want this feature to! I'm using video doorbell with this project, when doorbell event triggered, video showed up in about 3-4s. a gop cache will make the stream open in realtime.

thanks everyone in advance!!

@ethaniel
Copy link

I have a live stream, where I have multiple webcams in one single location (a zoo). I switch between them every 20 seconds. This feature would help make the switch quick and smooth.

@reloadman
Copy link

In my opinion, this is a very useful feature that will allow the mediamtx to be used in video surveillance projects. I'm eagerly awaiting its implementation!

@jean343
Copy link

jean343 commented Jan 15, 2025

Thank you for highlighting this issue! We’re actively working on a fix and have successfully gotten the RTSP path working so far. We’re continuing to refine the solution and will contribute the fix to the repository once it’s ready.

We appreciate your patience and look forward to improving this together!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request general
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants