Skip to content

Feature: Add option to unwrap MPEG-TS from RTSP#5476

Merged
aler9 merged 18 commits intobluenviron:mainfrom
EricHenry:mpegts-demuxing
Mar 17, 2026
Merged

Feature: Add option to unwrap MPEG-TS from RTSP#5476
aler9 merged 18 commits intobluenviron:mainfrom
EricHenry:mpegts-demuxing

Conversation

@EricHenry
Copy link
Contributor

Closes: #3811

I took the advice of the comment: #3811 (comment) to handle unwrapping of the MPEG-TS container into it's individual tracks. This feature is contained behind a configuration flag and is an opt-in only feature. This feature should not effect user's who do not need it.

Summary of changes:

rtp_mpegts_reader: Used to extract mpegts payloads from the RTP packets.
mpegts_demuxer: setups up and runs the demuxing flow

@aler9
Copy link
Member

aler9 commented Feb 18, 2026

This feature is quite useful, the implementation needs some work. The first step is probably to move the MPEG-TS demuxer and muxer inside gortsplib. This allows to have access to raw 188-long MPEG-TS packets. These can then be fed into the MPEG-TS reader inside MediaMTX.

@EricHenry
Copy link
Contributor Author

thanks for the feedback @aler9 , Let me get to work on migrating that over

go.mod Outdated
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/bluenviron/gortsplib/v5 => github.com/EricHenry/gortsplib/v5 v5.0.0-20260222205204-d23437b42934
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make sure to remove this once bluenviron/gortsplib#1007 looks good and is merged.

@EricHenry
Copy link
Contributor Author

@aler9 I got rid of the separate mpegts reader after I made the changes to bluenviron/gortsplib#1007 let me know how the latest update looks and if you'd like to see any additional changes.

Thanks!!

@EricHenry
Copy link
Contributor Author

updated to use the latest changes from bluenviron/gortsplib#1007 thanks for the feedback on that one!

@ingalls
Copy link

ingalls commented Mar 9, 2026

@aler9 We've been testing this extensively in production and haven't had any issues so far, are there any additional considerations to merging it?

@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 65.62500% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.51%. Comparing base (c8e07b5) to head (56d3d96).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/servers/rtsp/mpegts_demuxer.go 63.33% 13 Missing and 9 partials ⚠️
internal/servers/rtsp/session.go 69.44% 9 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5476      +/-   ##
==========================================
- Coverage   62.51%   62.51%   -0.01%     
==========================================
  Files         202      203       +1     
  Lines       17131    17226      +95     
==========================================
+ Hits        10709    10768      +59     
- Misses       5547     5572      +25     
- Partials      875      886      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aler9 aler9 force-pushed the mpegts-demuxing branch from d538417 to a62a1d2 Compare March 17, 2026 17:50
@aler9
Copy link
Member

aler9 commented Mar 17, 2026

I refactored a little in order to conform to standards and cover some edge cases that would have caused a panic (i.e. PAUSE + MPEG-TS demuxing). In the process we lost the ability to impose a timeout to MPEG-TS track recognition, you can readd it in a following PR if you want. This has been merged, thank you very much.

@aler9 aler9 merged commit f98c9c5 into bluenviron:main Mar 17, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support unwrapping RTSP MPEG-TS tracks

3 participants