[TV] - HD-PVR TV freezes After Channel Change When using SPDIF (1 Viewer)

mm1352000

Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Hello again

    Warning: some of the info below is quite technical!

    Channel changing with a capture device is always going to be interesting. It happens like this:
    1. Watching channel A, select channel B. MediaPortal tells TV Server to change channel.
    2. TV Server tells blaster to send command to switch to channel B. The blaster starts doing its thing - this carries on in the background of the following steps.
    3. TV Server goes through channel change for an analog tuner (ie. make sure correct inputs are selected).
    4. TV Server/TsWriter start waiting for PMT to determine what audio, video and subtitle streams will be present.
    5. PMT received, wait for audio and video.
    6. Audio and video seen, TV Server tells MediaPortal it has finished changing channel.
    7. MediaPortal sets up TsReader splitter waits to receive PMT.
    8. TsReader receives PMT, reads and decodes and tells MediaPortal what video, audio and subtitle streams are present.
    9. MediaPortal connects appropriate/configured codecs and tells TsReader and the codecs to start doing their jobs, the result being that you see video and hear audio.
    Now, the "interesting" thing in all this is... timing and PMT.
    MP and TV Server can (and usually do) complete a whole channel change sequence before the external tuner has finished changing channel.
    Everything that is done during the channel change, especially selection of codecs, tends to be done as if you were still streaming channel A.
    Thus the whole chain from HD-PVR through to your screen will see and have to cope with any glitches that are generated as a natural consequence of the external tuner changing from channel A to B.
    By glitches, I mean:
    1. The change from channel A to nothing.
    2. The nothingness itself... which tends to be garbage.
    3. The change from nothing to channel B.
    These glitches propagation through the entire chain: HD-PVR, TsWriter, HDD, streaming server and RTSP connection (for multi-seat), TsReader, codecs and renderer.

    PMT is a "clump" of info about the video, audio and subtitle streams that are present. This info is produced by the HD-PVR and parsed by TsWriter and TsReader. TsWriter (and TV Server in general) don't really care about the content of the PMT except that it determines what streams are included in the timeshift file. For the purposes of an HD-PVR that never changes, so TV Server tends to be pretty immune the the glitches. A key point to keep in mind is that TV Server doesn't remove the glitches either - it can't, because it has no idea when the external tuner actually finishes tuning. Everything just flows right on through to MP (or XBMC or whatever other front end is in use).

    The most fragile parts of the chain are the codecs and the RTSP connection (and I suppose TsReader to a lesser degree). When a codec tries to decode garbage it will often result in visible pixelation/freezing or audible pops. My understanding (and @Owlsroost will surely correct me!) is that failure of the audio codec can cause the video to stop as well.

    1. Start watching live TV change.

    2. Hit channel + button. See ir blaster changing channel on DVR. Picture and audio freeze.

    3. Hit pause and then play.

    4. Plays normally.

    5. Rewind to beginning of live buffer.

    6. Plays through channel change without freezing.
    I think the most interesting parts of all of this are #3 and #6.
    Both are telling me maybe in this particular case the absence of data (ie. the codecs and/or TsReader running out data to decode) is the issue.
    Of further interest is that this only happens with S/PDIF. I guess the difference is that from the HD-PVR's perspective, S/PDIF audio data is either present or not. In other words, there is a marked glitch. With line audio, the absence of signal is just silence...

    I think:
    • it would be worthwhile to try to reproduce the problem on a single-seat system (ie. eliminate RTSP)
    • it would be worthwhile to try different audio codecs

    @Owlsroost
    Whaddaya think?
    Is there anything that we can do on the TV Server side or in TsWriter to improve the situation? I'm thinking things like suppressing PMT changes by waiting for the second (or even third) PMT before allowing the channel change to complete.

    Note: with a Colossus or change involving switching of inputs, often there will be 3 PMTs seen:
    1. Old channel PMT.
    2. Default PMT (indicating input not detected).
    3. New channel PMT.

    mm
     

    cwchapma

    Portal Pro
    October 15, 2006
    56
    34
    48
    Home Country
    Canada Canada
    Warning: some of the info below is quite technical!

    Thanks for the all the info. It does give me a better understanding of what's going on. I saw "pmt" in the logs and wondered what it was.

    1. Start watching live TV change.

    2. Hit channel + button. See ir blaster changing channel on DVR. Picture and audio freeze.

    3. Hit pause and then play.

    4. Plays normally.

    5. Rewind to beginning of live buffer.

    6. Plays through channel change without freezing.
    I think the most interesting parts of all of this are #3 and #6.
    Both are telling me maybe in this particular case the absence of data (ie. the codecs and/or TsReader running out data to decode) is the issue.

    I was guessing the same. I think the same thing happens when comskip overloads the system and it ends up skipping some of the live tv and running out of data.

    I think:
    • it would be worthwhile to try to reproduce the problem on a single-seat system (ie. eliminate RTSP)
    • it would be worthwhile to try different audio codecs

    I have tried different audio codecs since it seemed dependent on the type of audio input. There was no change.
    If I run the client on the machine I'm using as a server, would that eliminate RTSP or is there something different in the install for a single seat?

    Thanks again for look at this.

    Clint
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    I have tried different audio codecs since it seemed dependent on the type of audio input. There was no change.
    Okay.


    If I run the client on the machine I'm using as a server, would that eliminate RTSP or is there something different in the install for a single seat?
    Yes, when running MP in single-seat RTSP is not used.

    If I run the client on the machine I'm using as a server, would that eliminate RTSP or is there something different in the install for a single seat?
    There is an easier solution:
    http://wiki.team-mediaportal.com/1_...diaPortal_Configuration/22_TV/5_Debug_Options
    This is true... but single-seat is more reliable in general, so I'd prefer results from that environment. ;)

    mm
     

    cwchapma

    Portal Pro
    October 15, 2006
    56
    34
    48
    Home Country
    Canada Canada
    Running the the mediaportal client on the server doesn't seem to have the same issue. It stutters a bit but doesn't freeze.

    So does that give some clue as to how to get it working on a network client?
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    Running the the mediaportal client on the server doesn't seem to have the same issue. It stutters a bit but doesn't freeze.
    Hmmm, okay - this is good to know... and I suspected that might be the case.

    So can you confirm that the behaviour is consistent?
    ie. there is consistent freeze in the multi-seat scenario, and it consistently stutters but doesn't freeze in the single-seat scenario

    So does that give some clue as to how to get it working on a network client?
    Not really for me. It proves that the issue is a client side or RTSP issue... which I was already pretty sure of.
    From here you really need assistance from somebody familiar with TsReader and RTSP to find some time to look into the problem.
    @Owlsroost is the resident expert in that domain, and @georgius may also have some comments.

    At this point I would also try the suggestion from HomeY to further narrow down the issue.
     
    Last edited:

    cwchapma

    Portal Pro
    October 15, 2006
    56
    34
    48
    Home Country
    Canada Canada
    UNC paths seem to fix the issue on a network client. I think it might be dropping a few more frames. That's probably usable for me.

    RTSP would be nice but this is a big step forward. Thanks @HomeY and @mm1352000.

    If anybody has any ideas about how to get RTSP to work, I'd be happy to test them out. It would be nice if this just worked by default plus I imagine there's a reason RTSP is the default. This ends up being just one more special configuration I need to set. I've already got a lot of those. :)

    Thanks again,
    Clint
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,577
    8,224
    Home Country
    New Zealand New Zealand
    UNC paths seem to fix the issue on a network client. I think it might be dropping a few more frames. That's probably usable for me.



    RTSP would be nice but this is a big step forward. Thanks @HomeY and @mm1352000.
    Right - excellent. :)



    If anybody has any ideas about how to get RTSP to work, I'd be happy to test them out. It would be nice if this just worked by default plus I imagine there's a reason RTSP is the default. This ends up being just one more special configuration I need to set. I've already got a lot of those. :)
    Maybe you could try this TsReader which apparently has some improvements to the RTSP handling in TsReader:
    https://forum.team-mediaportal.com/...reader-development.102693/page-86#post-989589
     

    cwchapma

    Portal Pro
    October 15, 2006
    56
    34
    48
    Home Country
    Canada Canada
    I tried opening the rtsp stream in VLC. It had pretty much the same problem only it didn't just freeze it gave up and closed the stream. If the stream was delayed a bit from live, it would stutter through the channel change and play fine after as well.[DOUBLEPOST=1367464122][/DOUBLEPOST]Tried v73 of the TsReader.ax you suggested. No change. Thanks for the suggestion though.
     

    Owlsroost

    Retired Team Member
  • Premium Supporter
  • October 28, 2008
    5,540
    5,038
    Cambridge
    Home Country
    United Kingdom United Kingdom
    Based on the fact that a UNC path works (which basically operates like single-seat mode but with the timeshift file on a remote drive), and that VLC gives up (presumably because it's not getting any data, and times out after a while), I suspect that this is a problem with the RTSP streaming server in TV server.

    In timeshift (live) mode TsReader will not give up and drop the stream because it assumes that live TV is everlasting, so it just freezes if the data stops. If the video stops but the audio continues then the video decode filter may have hung, or the video is always late so it gets dropped before it can be rendered to the screen.

    When it gets stuck, what happens if you pause TV for a few seconds - does it fix it ?
     

    Users who are viewing this thread

    Top Bottom