1. 27 May, 2018 3 commits
  2. 25 May, 2018 6 commits
  3. 24 May, 2018 6 commits
  4. 22 May, 2018 5 commits
  5. 21 May, 2018 6 commits
  6. 20 May, 2018 8 commits
  7. 19 May, 2018 5 commits
    • Martin Vignali's avatar
    • Martin Vignali's avatar
      644130bc
    • Aman Gupta's avatar
      avformat/mpegts: add merge_pmt_versions option · 16b4f97b
      Aman Gupta authored
      This new optional flag makes it easier to deal with mpegts
      samples where the PMT is updated and elementary streams move
      to different PIDs in the middle of playback.
      
      Previously, new AVStreams were created per PID, and it was up
      to the user to figure out which streams had migrated to a new PID
      (by iterating over the list of AVProgram and making guesses), and
      switch seamlessly to the new AVStream during playback.
      
      Transcoding or remuxing these streams with ffmpeg on the CLI was
      also quite painful, and the user would need to extract each set
      of PIDs into a separate file and then stitch them back together.
      
      With this new option, the mpegts demuxer will automatically detect
      PMT changes and feed data from the new PID to the original AVStream
      that was created for the orignal PID. For mpegts samples with
      stream_identifier_descriptor available, the unique ID is used to
      merge PIDs together. If the stream id is not available, the demuxer
      attempts to map PIDs based on their position within the PMT.
      
      With this change, I am able to playback and transcode/remux these
      two samples which previously caused issues:
      
          https://tmm1.s3.amazonaws.com/pmt-version-change.ts
          https://kuroko.fushizen.eu/videos/pid_switch_sample.ts
      
      I also have another longer sample in which the PMT changes
      repeatedly and ES streams move to different pids three times
      during playback:
      
          https://tmm1.s3.amazonaws.com/multiple-pmt-change.ts
      
      Demuxing this sample with the new option shows several new log
      messages as the PMT changes are handled:
      
          [mpegts] detected PMT change (program=1, version=3/6, pcr_pid=0xf98/0xfb7)
          [mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xfb7
          [mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xfb8
          [mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xfb9
          [mpegts] detected PMT change (program=1, version=6/3, pcr_pid=0xfb7/0xf98)
          [mpegts] detected PMT change (program=1, version=3/4, pcr_pid=0xf98/0xf9b)
          [mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xf9b
          [mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xf9c
          [mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xf9d
          [mpegts] detected PMT change (program=1, version=4/5, pcr_pid=0xf9b/0xfa9)
          [mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xfa9
          [mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xfaa
          [mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xfab
          [mpegts] detected PMT change (program=1, version=5/6, pcr_pid=0xfa9/0xfb7)
      Signed-off-by: 's avatarAman Gupta <aman@tmm1.net>
      16b4f97b
    • Aman Gupta's avatar
      avformat/mpegts: keep track of PMT details in AVProgram/AVStream · 24579bf5
      Aman Gupta authored
      With these fields, the user has enough information to
      detect PMT changes and switch to new streams when the PMT
      is updated with new ES pids.
      
      To do so, the user would monitor the AVProgram they're interested
      in for changes to pmt_version. If the version changes, they would
      iterate over the program's streams to find new streams added with
      the updated version number.
      
      If new versions of streams are found, then the user would first try
      to replace existing streams where stream_identifier matched.
      If stream_identifier is not available, then the user would compare
      pmt_stream_idx instead to replace the stream that was previously
      at the same position within the PMT.
      Signed-off-by: 's avatarAman Gupta <aman@tmm1.net>
      24579bf5
    • Aman Gupta's avatar
      avformat: add fields to AVProgram/AVStream for PMT change tracking · 2b2f2f65
      Aman Gupta authored
      These fields will allow the mpegts demuxer to expose details about
      the PMT/program which created the AVProgram and its AVStreams.
      
      In mpegts, a PMT which advertises streams has a version number
      which can be incremented at any time. When the version changes,
      the pids which correspond to each of it's streams can also change.
      
      Since ffmpeg creates a new AVStream per pid by default, an API user
      needs the ability to (a) detect when the PMT changed, and (b) tell
      which AVStream were added to replace earlier streams.
      
      This has been a long-standing issue with ffmpeg's handling of mpegts
      streams with PMT changes, and I found two related patches in the wild
      that attempt to solve the same problem:
      
      The first is in MythTV's ffmpeg fork, where they added a
      void (*streams_changed)(void*); to AVFormatContext and call it from
      their fork of the mpegts demuxer whenever the PMT changes.
      
      The second was proposed by XBMC in
      https://ffmpeg.org/pipermail/ffmpeg-devel/2012-December/135036.html,
      where they created a new AVMEDIA_TYPE_DATA stream with id=0 and
      attempted to send packets to it whenever the PMT changed.
      Signed-off-by: 's avatarAman Gupta <aman@tmm1.net>
      2b2f2f65
  8. 18 May, 2018 1 commit