Kodi Community Forum

Full Version: HLS stream with different .ts segments
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I'm writing an app which manipulates an M3U8 HLS manifest and replace certain .ts segments in the middle of the stream.
Both TS file playback separately in Kody without a problem, but it seems that Kody can't continuously play the stream when switching between the two TS types.

Both TS files has same bitrates, profile, level, length, GOP structure and so on. Though they have different MPEG TS metadata.
Below are two TSINFO dumps from the two separate files:

File 1:
Code:
Reading from /some/path/file1_1.ts
Scanning 1000 TS packets

Packet 2 is PAT
Program list:
    Program 1 -> PID 1000 (4096)

Packet 3 is PMT with PID 1000 (4096)
  Program 1, version 0, PCR PID 01e1 (481)
  Program streams:
    PID 01e1 ( 481) -> Stream type 1b ( 27) H.264/14496-10 video (MPEG-4/AVC)
    PID 01e2 ( 482) -> Stream type 0f ( 15) 13818-7 Audio with ADTS transport syntax

Found 48 PAT packets and 24 PMT packets in 1000 TS packets

File 2:
Code:
Reading from /some/path/file2.ts
Scanning 1000 TS packets

Packet 1 is PAT
Program list:
    Program 1 -> PID 01e0 (480)

Packet 2 is PMT with PID 01e0 (480)
  Program 1, version 0, PCR PID 01e1 (481)
     Program info (5 bytes): 0e 03 c0 14 28
     maximum bitrate (3 bytes): c0 14 28
  Program streams:
    PID 01e1 ( 481) -> Stream type 1b ( 27) H.264/14496-10 video (MPEG-4/AVC)
        ES info (11 bytes): 28 04 4d 40 1f 3f 0e 03 c0 13 88
        Reserved (4 bytes): 4d 40 1f 3f
        maximum bitrate (3 bytes): c0 13 88
    PID 01e2 ( 482) -> Stream type 0f ( 15) 13818-7 Audio with ADTS transport syntax
        ES info (11 bytes): 0a 04 75 6e 64 00 0e 03 c0 00 a0
        Languages: und
        maximum bitrate (3 bytes): c0 00 a0

Found 2 PAT packets and 1 PMT packet in 1000 TS packets



This is an extract from Kodi's log that refers to the problem:
Code:
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [http] header='Content-Type: video/MP2T'
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [http] header=''
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] Continuity check failed for pid 0 expected 1 got 7
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] PAT:
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] sid=0x1 pid=0x1e0
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] new_program: id=0x0001
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] Filter: pid=0x1e0 type=1
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] PMT: len 53
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] sid=0x1 sec_num=0/0 version=0 tid=2
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] pcr_pid=0x1e1
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] program tag: 0x0e len=3
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] Filter: pid=0x1e1 type=0
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] stream=2 stream_type=1b pid=1e1 prog_reg_desc=
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] tag: 0x28 len=4
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] tag: 0x0e len=3
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] Filter: pid=0x1e2 type=0
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] stream=3 stream_type=f pid=1e2 prog_reg_desc=
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] tag: 0x0a len=4
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] tag: 0x0e len=3
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] pid=1e2 pes_code=0x1c0
16:36:23 T:123145358114816   DEBUG: ffmpeg[700003538000]: [mpegts] pid=1e1 pes_code=0x1e0
16:36:23 T:123145358114816   DEBUG: Previous line repeats 1 times.
16:36:23 T:123145358114816   ERROR: ffmpeg[700003538000]: [hls,applehttp] stream index inconsistency: index 3, 2 main streams, 4 subdemuxer streams



Can anyone suggest a fix for this?
Thanks
I don't think that *this* will work.

You could add the second stream to the manifest instead. Delete the unwanted segments in each stream (or let them point to localhost). This should force Kodi to switch between the streams if one segment returns a 404. At least if it follows the spec.

I'm not certain that this will work. Switching streams in the case of an error is most likely missing from Kodi, because there is no adaptive steam switching implemented.

I've seen a similar (and wrong) behaviour with the dash inputstream add-on.
Thanks membrane

I actually did get it to work by simulation. Meaning I copied some file1.ts files to another server, changed their names and stitched them into an hls manifest.
The playback was continuous. I'm pretty sure it's the difference in PAT or MPT (or both) that messes it up.
Also, I'm able to playback the stitches manifest on most other platforms including Android, iOS and Safari. Kodi is the only one to crash the playback.

Thanks.