1.16.0 - TSReader gets stuck when audio streams are advertised in PMT but not found in stream

Discussion in 'Archive' started by el Filou, May 31, 2017.

  1. el Filou
    • Premium Supporter

    el Filou MP Donator

    Joined:
    July 2, 2008
    Messages:
    119
    Likes Received:
    65
    Gender:
    Male
    Ratings:
    +97 / 0
    Home Country:
    Belgium Belgium
    Show System Specs
    MediaPortal Version: 1.16.0

    Description
    Hello everyone.

    When trying to record a movie this weekend I noticed an issue on a TV channel: MP would give the generic "cannot play, video: AVC, audio: AC3" error dialog when trying to play back the recording from the beginning.
    When trying to play the same TV channel from the live point (i.e. during the movie), it would play just fine.
    The schedule was to start recording a few minutes before the movie (the evening weather info preceded it).

    I checked the TS file and did some other tests and found this:

    - Once the movie has started, the channel provides 3 audio streams: French, English, and Audio Description (visually impaired commentary, ISO code: 'qad'). It also provides two different DVB subtitle streams. (see attachment Equalizer_MediaInfo_mid_movie.txt)
    - Before the movie starts, only the Audio Description ('qad') audio stream, and only one DVB subtitle stream, are present. (see attachment Equalizer_MediaInfo_before_movie.txt)
    - MPC-HC with LAV Splitter has no problem playing back the recording from the beginning with only the 'qad' audio stream present, but then if I seek to somewhere during the movie, it doesn't dynamically detect the 2 additional audio streams.
    - If I open the recording with TS Doctor (v1.2, I still haven't bought v2.0), it only finds one audio stream (the 'qad'), but it does detect the two DVB subtitle streams and warns that they aren't present on the whole duration of the recording.
    - Starting a recording in the middle of the movie creates a file that can be played by MP without any problem.

    I suspect there are two different issues here:



    1. MP doesn't seem to know the "language" code 'qad' (= Audio Description). Is it possible that this prevents it from starting playback when the only audio stream present is using this code?
    It also doesn't seem to know 'qaa' which is the generic code for 'Original Audio' (in theory, should be used for movies for the soundtrack with the original language, but I've never seen it on my provider's channels).
    Could those two codes be added to the list of languages in TV support, so that they can be chosen in the configuration GUI and so MP shows the correct official names for them in TV plugin GUI?

    2. TS Reader doesn't seem to support dynamic detection and adding/removing streams once playback has started.
    Does DirectShow limits what can be done here, i.e. can pins be added or removed once the graph is built and is being played? Or is there a Transport Stream peculiarity making this hard to implement?
    Sometimes, I also see a situation on some channels, like Arte: it has French, German, English, and Audio Description audio streams, but when the movie being shown only provides some of those tracks, for example if only the French and German have sound, and I try to switch to English or Audio Description (because I have no way of knowing if those streams indeed are present), playback freezes or a black screen is displayed until I switch back to French or German and I seek once.

    I am attaching two MediaInfo output files, one when recording before the movie, and the other from during the movie.
    I am also attaching two sets of logs, from trying to play those two recordings. The one where the issue happens is Equalizer_logs_before_movie.zip

    If it helps, here are also two 1-minute cuts from those two recordings. I cut the files using 7-Zip "split file" functionality in order to avoid any TS reprocessing and give you exactly what MP recorded.

    Recording started before movie (causes issue): Equalizer_before_movie.ts
    Recording started during movie (plays fine): Equalizer_mid_movie.ts

    It would be fantastic if changes could be made to better support that case, thanks a lot in advance for your help.

    Steps to Reproduce:
    Try to play "Equalizer_before_movie.ts" using TSReader, MP gives playback error.
     

    Attached Files:

    • Like Like x 1
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. mm1352000
    • Team MediaPortal

    mm1352000 Development Group

    Joined:
    September 1, 2008
    Messages:
    21,527
    Likes Received:
    4,738
    Ratings:
    +8,205 / 17
    Home Country:
    New Zealand New Zealand
    Hello

    First, thank you for a fantastic bug report (y)

    I'll get straight to the point...

    You can't choose 'qad' (or 'qaa') as a preferred language code in MP Config. However that won't prevent MP from receiving/decoding such an audio stream, or from starting playback when the only audio stream that's present is a 'qad' one.

    Actually, it fully supports this.

    The issue seems to be that all audio streams are listed in the PMT (which is like a "contents" for the stream) even when some of them are not actually available.

    From the Equaliser_logs_before_movie.zip...
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - OnNewChannel: New channel found (PAT/PMT/SDT changed)
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - pcr pid: 0x 30
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - pmt pid: 0x 20
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - Video pid: 0x 30 type: H264 (0x1b) DescriptorData: 0x 0
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - Audio pid: 0x 40 type: AC3 (0x81) language: fre
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - Audio pid: 0x 41 type: AC3 (0x81) language: eng
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - Audio pid: 0x 42 type: AC3 (0x81) language: qad
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - Subtitle pid: 0x 50 type: DVB subtitle 2 (0x 6) language: fre
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - Subtitle pid: 0x 51 type: DVB subtitle 2 (0x 6) language: fre
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - OnNewChannel: OnRequestAudioChange()
    [2017-05-28 21:57:13,144] [137262f0] [1ab0] - demux:Wait for Audio stream selection :1
    [2017-05-28 21:57:13,154] [137262f0] [1ab0] - SetAudioStream : 0
    [2017-05-28 21:57:13,154] [137262f0] [1ab0] - Old Audio -1, New Audio 129
    [2017-05-28 21:57:13,154] [137262f0] [1ab0] - demux:Wait for Audio stream selection :0
    [2017-05-28 21:57:13,155] [137262f0] [1ab0] - OnNewChannel: New Audio stream type = 0x81

    In other words:
    1. MP's TsReader component finds the contents of the stream is 1 video stream, 3 audio streams and 2 subtitles streams.
    2. Your configuration causes MP to choose the French audio stream.

    Now TsReader waits to receive data from the French audio stream (for buffering/decoding etc. etc. etc.). The log file shows that the data never arrives:
    [
    [2017-05-28 21:57:13,482] [137262f0] [1ab0] - demux:endoffile
    ...
    [2017-05-28 21:57:15,132] [137262f0] [1ab0] - demux:endoffile
    [2017-05-28 21:57:15,142] [137262f0] [1ab0] - demux:confused:tart() Failed due to timeout : BytesProcessed:52428800, DTS/PTS count = 2129/2839, BVI=1, BAI=0

    TsReader reads to the end of the file and doesn't find any data from the French audio stream.

    Streams that don't have audio are not supported.
    The above looks like a scenario where no audio is available, and so playback fails.

    Playback succeeds when you try to view the stream during the movie because the advertised audio streams are actually available.


    In summary: it looks like the problem is that the stream provider is advertising the presence of streams that aren't actually available. That's naughty. It's no surprise that TsReader and other software have problems with this.
     
    • Agree Agree x 1
  4. el Filou
    • Premium Supporter

    el Filou MP Donator

    Joined:
    July 2, 2008
    Messages:
    119
    Likes Received:
    65
    Gender:
    Male
    Ratings:
    +97 / 0
    Home Country:
    Belgium Belgium
    Show System Specs
    Hello again.

    After your response, I modified MediaPortal.xml to manually add 'qad' to the preferred languages, and it was fine for a moment as the problem was only occuring on one channel. The only annoyance is that as qad is not in the official list of supported language codes, MP's config tool removed it every time I opened it to change some other config setting, but I could live with it.
    However, I know have more problems: my TV provider has started doing this with other channels I regularly watch, and it always advertises all the audio streams even if not present:
    - some channels advertise French/German/English/qad, but only French/German is present in the stream during some programs.
    - some channels advertise French/English, but only French is present in the stream during some programs.
    - some channels advertise French/English/qad, but only qad is present in the stream during some programs.
    - some channels advertise English/French, but only English is present in the stream during some programs.

    I think you're starting to get a picture of where I'm going: I'm now unable to watch many channels with MP without exiting, going to TV languages screen in the config tool, changing the priority list to put the language present in the stream of the channel I want to watch on top, and then opening MP again, and I have to do that again each time I want to switch channels. And for those channels where I need 'qad', I additionally need to manually edit MediaPortal.xml every time. :(

    I've tried opening support tickets with my provider, they said TV on PC is unsupported (of course... :rolleyes:), and that nobody using a CI card with their TV's integrated tuner has reported any problems, so in other words I'm stuck.
    One way I can work around this issue is to enable "Use Video codecs when playing .ts", which uses LAV Splitter which somehow manages to work around this issue, but I lose the ability to watch TV live or to watch a program that is currently recording.

    Is there really nothing that can be done in TSReader to work around this?
    In TS Doctor, when I open such a recording, it says:

    Would it be possible to make TSReader to try to switch to the next advertised/preferred audio stream if the chosen one is not found in the TS, and so on until it finds one actually present? Maybe only as a debug option not enabled by default? That would be awesome of you.

    If that's not possible, could you at least open a JIRA to add 'qad' and 'qaa' to the list of supported lanuage codes? At least that way I wouldn't need to manually edit MediaPortal.xml each time.

    Thanks a lot for your help again.
     
  5. mm1352000
    • Team MediaPortal

    mm1352000 Development Group

    Joined:
    September 1, 2008
    Messages:
    21,527
    Likes Received:
    4,738
    Ratings:
    +8,205 / 17
    Home Country:
    New Zealand New Zealand
    Hello again

    I've checked the Equalizer_before_movie.ts sample again and unfortunately I can't see any indicator in the PMT that the streams aren't actually present/active.

    Are you able to supply a TS dump rather than a recording?
    TS Dumps - MediaPortal 1 - MediaPortal Wiki

    @Owlsroost
    Any thoughts?

    TS Doctor would have the ability to identify invalid PIDs because it has access to the entire recording. It can scan the recording from start to finish and confirm that there are zero packets from the given PIDs. That's impossible for live TV (obviously we can't scan future packets!).

    That's a question for Owlsroost.
    If the only way to determine that an audio stream isn't present is to wait for packets to be received then this could make changing to these channels quite slow.

    The list of language codes comes from .NET/Windows. It's possible to add custom codes with a little code:
    How to: Create Custom Cultures
     
    • Like Like x 1
    • Thank You! Thank You! x 1
  6. Owlsroost
    • Team MediaPortal

    Owlsroost Development Group

    Joined:
    October 28, 2008
    Messages:
    5,537
    Likes Received:
    2,829
    Location:
    Cambridge
    Ratings:
    +4,131 / 1
    Home Country:
    United Kingdom United Kingdom
    Show System Specs
    The problem is that the audio stream selection logic and user preferences are handled in the MP TV player code. TsReader just creates the list of theoretically available audio streams (from the PAT/PMT) then requests MP player to choose one. TsReader never knows what is the preferred language etc. - it just gets told by the player which audio stream to select for parsing. Also different audio streams may need the player to re-build the filter graph with a different audio decoder filter, which is another reason why MP player has to be involved.

    So I think what could be done is:

    1. TsReader creates the initial audio stream list.
    2. It asks MP player to choose one audio stream.
    3. TsReader attempts to parse that audio.
    4. If parsing is successful (it's seen enough packets in a short time e.g. 1 second) then stop searching - the stream is playable.
    5. If there are no audio packets (for the selected stream) received, then it removes that audio stream from the list and asks MP player to choose another audio stream.
    Repeat 3-4-5 until it's tried all the streams, and either found a playable stream or MP player has timed out waiting for playback to start.

    TsReader could keep a 'packet received rate' table, so that it knows (after a while) which audio streams are actually (currently) being received. This might make the stream list management more intelligent/faster i.e. all streams not received are hidden in the list given to MP player. If a stream starts to arrive later then it triggers a request to MP player to choose an audio stream etc.
     
    • Like Like x 2
  7. mm1352000
    • Team MediaPortal

    mm1352000 Development Group

    Joined:
    September 1, 2008
    Messages:
    21,527
    Likes Received:
    4,738
    Ratings:
    +8,205 / 17
    Home Country:
    New Zealand New Zealand
    Mmmm, that's generally what I had in mind, however on further consideration I wonder if this would be better handled in TsWriter rather than TsReader. I mean, TsWriter already waits to confirm that video and/or audio packets are received before starting to write to file. The TVE 3.5 TsWriter goes even further and waits for unencrypted video and/or audio. Neither version currently wait for packets from all audio PIDs. They could be made to do that, though it would be quite... challenging.
     
    • Thank You! Thank You! x 1
    • Informative Informative x 1
  8. el Filou
    • Premium Supporter

    el Filou MP Donator

    Joined:
    July 2, 2008
    Messages:
    119
    Likes Received:
    65
    Gender:
    Male
    Ratings:
    +97 / 0
    Home Country:
    Belgium Belgium
    Show System Specs
    Hello everyone, thank you again for all the background technical information behind this issue, and sorry for the late reply, I had been pretty busy the last few weeks.

    I created a raw TS packet dump as asked by @mm1352000 : MP audio channel not present – Google Drive

    I also included in this linked shared folder, in case that could be useful to you:
    - a screenshot of TV Service Config that shows various info of the tuned channel during the test
    - logs from MediaInfo and TS Doctor of a normal recording I did of the same channel during the same programme, just after the raw packet dump (I kept that recording just in case but didn't upload it as you already have the transponder dump)
    - screenshot of MP that shows audio stream selection, including English and 'qad' that are actually not present in the TS.

    Concerning the "custom locale" to add qad and qaa codes, I've had a look at the dev page but I don't know much about .NET so I'll try to see if I can find an example of a custom locale file and modify it manually as I guess it's just serialized binary info?

    Thank you all again for your help, this is greatly appreciated!
     
  9. mm1352000
    • Team MediaPortal

    mm1352000 Development Group

    Joined:
    September 1, 2008
    Messages:
    21,527
    Likes Received:
    4,738
    Ratings:
    +8,205 / 17
    Home Country:
    New Zealand New Zealand
    Hello again

    I haven't had a chance to look at the TS dump yet... but that's because I've been busy fixing it by implementing what I'm calling "audio confirmation" in TVE 3.5's TsWriter.

    The intention of the feature is that the PMT produced by TsWriter will reflect the audio streams that are actually available. As it stands right now that means that audio streams won't be added to the PMT unless unencrypted packets are actually seen. Once a stream has been included in the PMT, it won't be removed - even if packets stop being received - unless there's an upstream dynamic PMT update to remove it.

    The feature is only enabled for recordings at the moment because I didn't want to slow down live TV channel changes. I'd definitely consider adding a debug option to enable the feature for live TV in future. For now the recording option can be used as a workaround for live TV (start a recording, then start watching the recording).
     
    • Thank You! Thank You! x 2
  10. mm1352000
    • Team MediaPortal

    mm1352000 Development Group

    Joined:
    September 1, 2008
    Messages:
    21,527
    Likes Received:
    4,738
    Ratings:
    +8,205 / 17
    Home Country:
    New Zealand New Zealand
    About the channel (Arte Belgique HD, right?)...

    Is it a "normal" - one that channel that shows one program after another?
    ...or is it more like a "box office" or "near-video-on-demand" channel where the channel is inactive (not showing programs) sometimes?
     
    • Like Like x 1
  11. el Filou
    • Premium Supporter

    el Filou MP Donator

    Joined:
    July 2, 2008
    Messages:
    119
    Likes Received:
    65
    Gender:
    Male
    Ratings:
    +97 / 0
    Home Country:
    Belgium Belgium
    Show System Specs
    Hello, thank you so much for this development, this is awesome! :)

    Yes, the channel name from the provider is 'Arte Belgique HD', and it's a normal public channel that shows programmes all the time one after the other.

    A debug option for Live TV would be fine, as we pretty much always change channels using the TV guide information to go directly to the channel we want so if 'zapping' time takes a bit longer it's not the end of the world.
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!