Skip to content

Conversation

kirpicheff
Copy link

Problem

TS muxer in datarhei/joy4 causes video freezing after ~5-6 minutes of streaming due to:

  • TS discontinuity errors
  • PCR timestamp wraparound issues
  • Buffer management problems
  • Continuity counter conflicts

Solution

  • ✅ Individual continuity counters for each stream
  • ✅ Proper PCR timing with wraparound handling
  • ✅ Periodic PAT/PMT sending every 1 second
  • ✅ Simple timestamp conversion (no complex 90kHz clock)
  • ✅ Improved buffer management

Testing

  • Tested with RTMP input → SRT output streaming
  • Resolves video freezing after 5+ minutes
  • Eliminates TS discontinuity errors in VLC
  • Stable long-term streaming confirmed

Files changed

  • format/ts/muxer.go - Main TS muxer fixes
  • format/ts/tsio/tsio.go - PCR/PTS timestamp handling

- Replace packet counter-based PCR with timestamp-based PCR generation
- Set PCR PID to first stream (usually video) for proper synchronization
- Send PCR every 80ms based on actual video timestamps
- Remove incorrect PCR generation from audio packets
- This fixes 'picture is too late' warnings and improves stream stability
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.

1 participant