xbmc / inputstream.adaptive

kodi inputstream addon for several manifest types
Other
451 stars 241 forks source link

[HLS] .ts stream won't play #733

Open matthuisman opened 3 years ago

matthuisman commented 3 years ago

Test stream: https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/ia.strm manifest: https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/sub.m3u8 segment 1: https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/segment162604874_1200_av-p.ts

plays fine using ffmpeg: https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/ffmpeg.strm

Looks like it picks up the audio stream ok, but fails on the video stream

2021-10-21 09:55:12.190 T:3204    DEBUG <general>: CVideoGUIInfo::InitCurrentItem(https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/master.m3u8)
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: Download finished: https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/master.m3u8
2021-10-21 09:55:12.194 T:2692     INFO <general>: AddOnLog: inputstream.adaptive: Successfully parsed manifest file. #Periods: 1, #Streams in first period: 2, Type: live, Download speed: 7823100.7344 Bytes/s
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: New period, dispose sample decrypter and reinitialize
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: Stream selection conditions: w: 1438, h: 821, bw: 62584805
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: ASSUREDBUFFERDURATION selected: 60 
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: MAXBUFFERDURATION selected: 120 
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: ASSUREDBUFFERDURATION selected: 60 
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: MAXBUFFERDURATION selected: 120 
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: ASSUREDBUFFERDURATION selected: 60 
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: MAXBUFFERDURATION selected: 120 
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: ASSUREDBUFFERDURATION selected: 60 
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: MAXBUFFERDURATION selected: 120 
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: GetCapabilities()
2021-10-21 09:55:12.194 T:2692     INFO <general>: Creating Demuxer
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: GetStreamIds()
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: GetStream(1001)
2021-10-21 09:55:12.194 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: GetStream(1002)
2021-10-21 09:55:12.195 T:2692    DEBUG <general>: CDVDDemuxClient::RequestStream(): added/updated stream 1001 with codec_id 27
2021-10-21 09:55:12.195 T:2692    DEBUG <general>: CDVDDemuxClient::RequestStream(): added/updated stream 1002 with codec_id 86018
2021-10-21 09:55:12.195 T:2692     INFO <general>: Opening stream: 1001 source: 256
2021-10-21 09:55:12.195 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: OpenStream(1001)
2021-10-21 09:55:12.195 T:2692    DEBUG <general>: CurlFile::Open(0x2382b3b9ae0) https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/sub.m3u8
2021-10-21 09:55:12.198 T:3204    DEBUG <general>: Streaming media detected... using D:\ia_tests\hls_ia_fails\ia.strm to find a thumb
2021-10-21 09:55:12.199 T:3204    DEBUG <general>: CPlayerGUIInfo::InitCurrentItem(https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/master.m3u8)
2021-10-21 09:55:12.204 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: Download finished: https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/sub.m3u8
2021-10-21 09:55:12.204 T:4564    DEBUG <general>: CurlFile::ParseAndCorrectUrl() adding custom header option 'connection: keep-alive'
2021-10-21 09:55:12.204 T:4564    DEBUG <general>: CurlFile::Open(0x2382b3b80e0) https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/segment162604874_1200_av-p.ts
2021-10-21 09:55:12.299 T:3204    DEBUG <general>: ------ Window Init (DialogBusy.xml) ------
2021-10-21 09:55:12.516 T:4564    DEBUG <general>: AddOnLog: inputstream.adaptive: Download https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/segment162604874_1200_av-p.ts finished, avg speed: 12803948.00byte/s, current speed: 12803948.00byte/s
2021-10-21 09:55:12.516 T:4564    DEBUG <general>: CurlFile::ParseAndCorrectUrl() adding custom header option 'connection: keep-alive'
2021-10-21 09:55:12.516 T:4564    DEBUG <general>: CurlFile::Open(0x2382b3b8760) https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/segment162604875_1200_av-p.ts
2021-10-21 09:55:12.831 T:4564    DEBUG <general>: AddOnLog: inputstream.adaptive: Download https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/segment162604875_1200_av-p.ts finished, avg speed: 12825312.00byte/s, current speed: 12825312.00byte/s
2021-10-21 09:55:12.832 T:4564    DEBUG <general>: CurlFile::ParseAndCorrectUrl() adding custom header option 'connection: keep-alive'
2021-10-21 09:55:12.832 T:4564    DEBUG <general>: CurlFile::Open(0x2382b3ba160) https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/segment162604876_1200_av-p.ts
2021-10-21 09:55:13.149 T:4564    DEBUG <general>: AddOnLog: inputstream.adaptive: Download https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/segment162604876_1200_av-p.ts finished, avg speed: 12855760.00byte/s, current speed: 12855760.00byte/s
2021-10-21 09:55:13.149 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: current_bandwidth_: 10267534 
2021-10-21 09:55:13.149 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: bandwidth set: 35936369 
2021-10-21 09:55:13.154 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: current_bandwidth_: 10267534 
2021-10-21 09:55:13.154 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: bandwidth set: 35936369 
2021-10-21 09:55:13.160 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: GetStream(1001)
2021-10-21 09:55:13.160 T:2692  WARNING <general>: CVideoPlayer::OpenStream - Unsupported stream 1001. Stream disabled.
2021-10-21 09:55:13.160 T:2692     INFO <general>: Opening stream: 1002 source: 256
2021-10-21 09:55:13.160 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: OpenStream(1002)
2021-10-21 09:55:13.160 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: GetStream(1002)
2021-10-21 09:55:13.160 T:2692     INFO <general>: Finding audio codec for: 86018
2021-10-21 09:55:13.160 T:2692     INFO <general>: CDVDAudioCodecFFmpeg::Open() Successful opened audio decoder aac
2021-10-21 09:55:13.160 T:2692     INFO <general>: Creating audio thread
2021-10-21 09:55:13.161 T:3988    DEBUG <general>: Thread VideoPlayerAudio start, auto delete: false
2021-10-21 09:55:13.161 T:3988     INFO <general>: running thread: CVideoPlayerAudio::Process()
2021-10-21 09:55:13.161 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: EnableStream(1001: false)
2021-10-21 09:55:13.161 T:2692    DEBUG <general>: CVideoPlayer::SetCaching - caching state 2
2021-10-21 09:55:13.161 T:2692    DEBUG <general>: CDVDClock::SetSpeedAdjust - adjusted:0.000000
2021-10-21 09:55:13.161 T:2692     INFO <general>: CVideoPlayer::Process - eof reading from demuxer
2021-10-21 09:55:13.161 T:2692     INFO <general>: CVideoPlayer::OnExit()
2021-10-21 09:55:13.161 T:2692     INFO <general>: VideoPlayer: eof, waiting for queues to empty
2021-10-21 09:55:13.161 T:11540   DEBUG <general>: CApplication::OnAVChange: CApplication::OnAVChange
2021-10-21 09:55:13.161 T:2692     INFO <general>: Closing stream player 1
2021-10-21 09:55:13.162 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: EnableStream(1002: false)
2021-10-21 09:55:13.162 T:2692     INFO <general>: Waiting for audio thread to exit
2021-10-21 09:55:13.172 T:3988     INFO <general>: thread end: CVideoPlayerAudio::OnExit()
2021-10-21 09:55:13.172 T:3988    DEBUG <general>: Thread VideoPlayerAudio 3988 terminating
2021-10-21 09:55:13.172 T:2692     INFO <general>: Closing audio device
2021-10-21 09:55:13.172 T:2692     INFO <general>: Deleting audio codec
2021-10-21 09:55:13.172 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: Close()
2021-10-21 09:55:13.172 T:2692    DEBUG <general>: AddOnLog: inputstream.adaptive: Session::~Session()

ffmpeg output playing same stream

2021-10-21 09:27:41.898 T:6116    DEBUG <general>: ffmpeg[0x1e9ab782dc0X]: [hls] stream 0: start_time: 69555.7 duration: NOPTS
2021-10-21 09:27:41.898 T:6116    DEBUG <general>: ffmpeg[0x1e9ab782dc0X]: [hls] stream 1: start_time: 69555.7 duration: NOPTS
2021-10-21 09:27:41.898 T:6116    DEBUG <general>: ffmpeg[0x1e9ab782dc0X]: [hls] stream 2: start_time: 69555.7 duration: 30
2021-10-21 09:27:41.898 T:6116    DEBUG <general>: ffmpeg[0x1e9ab782dc0X]: [hls] format: start_time: 69555.7 duration: 30 (estimate from stream) bitrate=0 kb/s
2021-10-21 09:27:41.900 T:6116    DEBUG <general>: ffmpeg[0x1e9ab782dc0X]: [hls] After avformat_find_stream_info() pos: 193 bytes read:193 seeks:0 frames:37
2021-10-21 09:27:41.900 T:6116    DEBUG <general>: CDVDDemuxFFmpeg::Open - av_find_stream_info finished
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]: Input #0, hls, from 'https://raw.githubusercontent.com/matthuisman/ia_tests/master/hls_ia_fails/master.m3u8':
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:   Duration: 00:00:30.00, start: 69555.657089, bitrate: 0 kb/s
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:   Program 0 
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:     Metadata:
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:       variant_bitrate : 3096000
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:     Stream #0:0, 21, 1/90000: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv), 1920x1080 [SAR 1:1 DAR 16:9], Closed Captions, 29.97 tbr, 90k tbn, 59.94 tbc
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:     Metadata:
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:       variant_bitrate : 3096000
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:     Stream #0:1, 16, 1/90000: Audio: aac (HE-AAC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:     Metadata:
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:       variant_bitrate : 3096000
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:     Stream #0:2, 0, 1/90000: Data: timed_id3 (ID3  / 0x20334449)
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:     Metadata:
2021-10-21 09:27:41.900 T:6116     INFO <general>: ffmpeg[0x1e9ab782dc0X]:       variant_bitrate : 3096000
2021-10-21 09:27:41.900 T:6116    DEBUG <general>: CDVDDemuxFFmpeg::AddStream ID: 0
2021-10-21 09:27:41.901 T:6116    DEBUG <general>: CDVDDemuxFFmpeg::AddStream ID: 1
2021-10-21 09:27:41.901 T:6116    DEBUG <general>: CDVDDemuxFFmpeg::AddStream ID: 2
2021-10-21 09:27:41.901 T:6116     INFO <general>: Opening stream: 0 source: 256
2021-10-21 09:27:41.901 T:6116     INFO <general>: Creating video codec with codec id: 27
2021-10-21 09:27:41.901 T:6116     INFO <general>: CDVDVideoCodecFFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
2021-10-21 09:27:41.901 T:6116    DEBUG <general>: ffmpeg[0x1e9ab782dc0X]: [h264] nal_unit_type: 7(SPS), nal_ref_idc: 3
2021-10-21 09:27:41.901 T:6116    DEBUG <general>: ffmpeg[0x1e9ab782dc0X]: [h264] nal_unit_type: 8(PPS), nal_ref_idc: 3
2021-10-21 09:27:41.901 T:6116    DEBUG <general>: CDVDVideoCodecFFmpeg - Updated codec: ff-h264
2021-10-21 09:27:41.901 T:6116    DEBUG <general>: CVideoPlayerVideo::OpenStream - open stream with codec id: 27
2021-10-21 09:27:41.901 T:6116     INFO <general>: Creating video thread
2021-10-21 09:27:41.902 T:3652    DEBUG <general>: Thread VideoPlayerVideo start, auto delete: false
2021-10-21 09:27:41.902 T:3652     INFO <general>: running thread: video_thread
2021-10-21 09:27:41.902 T:3652    DEBUG <general>: CVideoPlayerVideo - CDVDMsg::GENERAL_PAUSE: 0
2021-10-21 09:27:41.902 T:6116     INFO <general>: Opening stream: 1 source: 256
2021-10-21 09:27:41.902 T:6116     INFO <general>: Finding audio codec for: 86018
2021-10-21 09:27:41.903 T:6116     INFO <general>: CDVDAudioCodecFFmpeg::Open() Successful opened audio decoder aac
CastagnaIT commented 1 year ago

tested again with Kodi 21 thanks to a recent change that i made on kodi core now show the problem, at least something where start investigate 2023-03-01 14:28:13.794 T:13624 error <general>: CVideoPlayerVideo::OpenStream: Codec id 27 require extradata.

CastagnaIT commented 1 year ago

looks like there is a problem in the tsDemuxer.cpp when fall here to get the stream info

https://github.com/xbmc/inputstream.adaptive/blob/4d4d0a332ba2b3ac77901594f5979bc1b8451f2d/src/TSReader.cpp#L221

dont find it and return false then try go on in the loop but never find it, so ReadPacket return false

https://github.com/xbmc/inputstream.adaptive/blob/4d4d0a332ba2b3ac77901594f5979bc1b8451f2d/src/TSReader.cpp#L22-L26

and then fails to initialize the video stream

playing the sample stream on VLC you can see more warnings: h264 warning: waiting for SPS/PPS

this means that h264 SPS/PPS has not be found on the first frames and so skip packet frames on our tsreader seem happens something similar SPS/PPS not found but for some reason isnt able to parse it on following frames/packets