Skip to content
New issue

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

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

Already on GitHub? # to your account

Live UDP DVB subtitles timing issue #1477

Open
jakubvojacek opened this issue Feb 3, 2025 · 0 comments
Open

Live UDP DVB subtitles timing issue #1477

jakubvojacek opened this issue Feb 3, 2025 · 0 comments

Comments

@jakubvojacek
Copy link

Hello

we have been doing some tests with DVB subtitles on our live streams and they work quite well, except for when the input UDP does not start with zero PTS.

For example when I got stream

Input #0, mpegts, from 'udp://239.0.2.95:1238?':
  Duration: N/A, start: 2015.326667, bitrate: N/A
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
  Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 640x360 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn
  Stream #0:1[0x101]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 960x540 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn
  Stream #0:2[0x102]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn
  Stream #0:3[0x103](cze): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 127 kb/s
  Stream #0:4[0x104](cze): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006) (hearing impaired)

and packager command

packager-linux-x64   'in=udp://239.0.2.95:1238?reuse=1&buffer_size=25000000,stream=0,bandwidth=400000,init_segment=video_cenc_0.mp4,segment_template=v_cenc_0/$Number$.mp4,playlist_name=video_cenc_0.m3u8' 'in=udp://239.0.2.95:1238?reuse=1&buffer_size=25000000,stream=1,bandwidth=1000000,init_segment=video_cenc_1.mp4,segment_template=v_cenc_1/$Number$.mp4,playlist_name=video_cenc_1.m3u8' 'in=udp://239.0.2.95:1238?reuse=1&buffer_size=25000000,stream=2,bandwidth=2500000,init_segment=video_cenc_2.mp4,segment_template=v_cenc_2/$Number$.mp4,playlist_name=video_cenc_2.m3u8' 'in=udp://239.0.2.95:1238?reuse=1&buffer_size=25000000,stream=3,bandwidth=128000,language=cze,init_segment=audio_cenc_cze_stereo.mp4,segment_template=a_cenc_cze_stereo/$Number$.mp4,playlist_name=audio_cenc_cze_stereo.m3u8' 'in=udp://239.0.2.95:1238?reuse=1&buffer_size=25000000,stream=text,init_segment=subtitle_cenc_cze.mp4,segment_template=s_cenc_cze/$Number$.mp4,language=cze,dash_only=1' --time_shift_buffer_depth 15000 \
--mpd_output /ssd/motv/channels/live/test/ct-d-ct-art-10-379-cenc.mpd \
--hls_master_playlist_output /ssd/motv/channels/live/test/ct-d-ct-art-10-379-cenc.m3u8 \
--hls_playlist_type LIVE \
--clear_lead 0 \
--fragment_duration 3.2 \
--segment_duration 3.2 \
--suggested_presentation_delay 10 \
--min_buffer_time 7 \
--minimum_update_period 6 \
--allow_approximate_segment_timeline

the MPD looks like this

<?xml version="1.0" encoding="UTF-8"?>
<!--Generated with https://github.com/shaka-project/shaka-packager version v3.4.2-c819dea-release-->
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" profiles="urn:mpeg:dash:profile:isoff-live:2011" minBufferTime="PT7S" type="dynamic" publishTime="2025-02-03T13:25:14Z" availabilityStartTime="2025-02-03T12:51:01Z" minimumUpdatePeriod="PT6S" timeShiftBufferDepth="PT15000S" suggestedPresentationDelay="PT10S">
  <Period id="0" start="PT0S">
    <AdaptationSet id="0" contentType="video" maxWidth="1920" maxHeight="1080" frameRate="90000/1800" segmentAlignment="true" par="16:9">
      <SupplementalProperty schemeIdUri="urn:mpeg:mpegB:cicp:MatrixCoefficients" value="1"/>
      <SupplementalProperty schemeIdUri="urn:mpeg:mpegB:cicp:ColourPrimaries" value="1"/>
      <SupplementalProperty schemeIdUri="urn:mpeg:mpegB:cicp:TransferCharacteristics" value="1"/>
      <Representation id="0" bandwidth="400000" codecs="avc1.4d401f" mimeType="video/mp4" sar="1:1" width="640" height="360">
        <SegmentTemplate timescale="90000" initialization="video_cenc_0.mp4" media="v_cenc_0/$Number$.mp4" startNumber="1">
          <SegmentTimeline>
            <S t="182435400" d="288000" r="8"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="1" bandwidth="1000000" codecs="avc1.4d401f" mimeType="video/mp4" sar="1:1" width="960" height="540">
        <SegmentTemplate timescale="90000" initialization="video_cenc_1.mp4" media="v_cenc_1/$Number$.mp4" startNumber="1">
          <SegmentTimeline>
            <S t="182435400" d="288000" r="8"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
      <Representation id="2" bandwidth="2500000" codecs="avc1.4d402a" mimeType="video/mp4" sar="1:1" width="1920" height="1080">
        <SegmentTemplate timescale="90000" initialization="video_cenc_2.mp4" media="v_cenc_2/$Number$.mp4" startNumber="1">
          <SegmentTimeline>
            <S t="182435400" d="288000" r="8"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
    <AdaptationSet id="1" contentType="audio" lang="cs" startWithSAP="1" segmentAlignment="true">
      <Representation id="3" bandwidth="128000" codecs="mp4a.40.2" mimeType="audio/mp4" audioSamplingRate="48000">
        <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
        <SegmentTemplate timescale="90000" initialization="audio_cenc_cze_stereo.mp4" media="a_cenc_cze_stereo/$Number$.mp4" startNumber="1">
          <SegmentTimeline>
            <S t="182162760" d="142080"/>
            <S t="182304840" d="288000" r="8"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
    <AdaptationSet id="2" contentType="text" lang="cs" segmentAlignment="true">
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle"/>
      <Representation id="4" bandwidth="140715" codecs="stpp" mimeType="application/mp4">
        <SegmentTemplate timescale="90000" initialization="subtitle_cenc_cze.mp4" media="s_cenc_cze/$Number$.mp4" startNumber="1">
          <SegmentTimeline>
            <S t="0" d="288000" r="639"/>
          </SegmentTimeline>
        </SegmentTemplate>
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

As you can see, the subtitles starts with <S t="0" d="288000" r="639"/> but the other tracks starts with 182162760/90000 timestamp, not zero.

This content is then unplayable by for example shaka-player.

I know I could "fix" this by re-encoding the input or always trying to start the ffmpeg and packager at the same time but that is sub-optimal. Do you think this could be fixed?

Thank you
Jakub

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant