Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gst-plugins-bad gst-plugins-bad
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 973
    • Issues 973
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 103
    • Merge requests 103
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GStreamerGStreamer
  • gst-plugins-badgst-plugins-bad
  • Issues
  • #1556
Closed
Open
Issue created Mar 22, 2021 by Andrew Gall@andy

mpegtsmux: Stream packets can be sent prior to first PAT/PMT

Since 1.18, by default the first stream created (based on the pad creation order) is considered the PCR stream. Yet this PCR stream may not be the first stream whose buffers' are muxed, which results in writing stream data prior to writing the PAT/PMT.

In 1.16, despite the logic introduced by 3f0463c4, it isn't until a few lines below that the stream is initially created. So despite logging that a PCR stream had been selected and calling tsmux_program_set_pcr_stream it did not have any effect. Afterwards the first stream used for output is selected as the PCR stream here.

So it appears quite intentional to choose the first program stream as the PCR stream. However, at least for my use case, it is common not to know if the first buffer will be audio or video until after linking the pipeline. In this case the behavior of 1.16 where it selects the first stream buffer for output as the PCR stream is needed.

I do hesitate to create an MR to remove that logic as I only have a limited familiarity with the code. Perhaps it would be better instead to ensure that the SI structures are written before the first stream data?

Reproduction: gst-launch-1.0 audiotestsrc num-buffers=1 timestamp-offset=1 ! avenc_aac ! aacparse ! .sink_101 mpegtsmux name=mux ! tsdemux ! fakesink videotestsrc num-buffers=1 ! x264enc ! mux.sink_102

In this case audio is selected as the PCR stream as it is linked first. Yet due to audio's 'timestamp-offset=1' the first video buffer is sent before the PAT/PMT. If you enable logging in the demuxer there will be a bunch of "PID 0x0066 Saw packet on a pid we don't handle" messages.

Assignee
Assign to
Time tracking