Audio Delay Option stuttering issue

Discussion in 'General Support' started by Eggert, July 14, 2014.

  1. Eggert
    • Premium Supporter

    Eggert MP Donator

    Joined:
    May 23, 2005
    Messages:
    70
    Likes Received:
    3
    Ratings:
    +4 / 0
    Hi,

    I just upgraded from MP 1.6.0 to MP 1.8.0 and use the LAV audio codecs.

    Since my Sony TV has a huge video lag, I need to calm down my AV receiver.
    I need an audio delay of round about 100ms. When I set the delay higher than ~40ms, every 400th frame there is a small stop (only a few ms) of the stream and the counter of the frames starts again (checked when using keystroke "CTRL-1" when watching TV in Mediaportal).
    Seems to be like a buffer is getting full and has to get resetted or something like that.



    I had this issue since MP 1.3.0 where I first experimented with the audio delay option.
    There I could manage to get a delay up to 70ms, but above this issue appeared.
    With MP 1.8.0 this option is even more sensitive as described above.

    I first thought this is a bug within the LAV codec but the developer said:
    "LAV only adjusts the audio timestamps when you apply a delay, not more. If something causes issues here, its not LAV.
    It works with any audio [means stereo or 5.1], and in theory any delay."
    This is why I posted here and not in the codec section.

    In the attachment you can find a TsReader.log and I think you can see the issue there, maybe for example here:
    "Pause 195 mS renderer clock to match provider/RTSP clock, A/V = 2/14"

    Any help is highly appreciated since I cannot live with audio and video being out of sync. :)
    If someone could verify this by setting the audio delay to 200ms and describes what happens, that would be nice.

    Thanks!
    Regards,
    Eggert
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. 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
    I can see what's happening in the log - I'll take a look at the code later.....
     
    • Thank You! Thank You! x 2
  4. 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
    Eggert - can you open up Regedit, navigate to 'HKEY_CURRENT_USER\Software\Team MediaPortal\TsReader' and open the "BufferingDelayInMilliSeconds" value.

    It is zero by default - please try changing it to (decimal) 200 or (hex) C8 - this will force TsReader.ax to buffer 200ms more data internally. It means that you'll have to wait 200ms longer after every channel change before it can start playing, though.

    See if that helps with the problem.
     
  5. Eggert
    • Premium Supporter

    Eggert MP Donator

    Joined:
    May 23, 2005
    Messages:
    70
    Likes Received:
    3
    Ratings:
    +4 / 0
    Hi Owlsroost,

    I just played a bit with that registry setting and finally put it up to (dec) 1500 ms and set LAV to 200 ms.
    I also tried registry to (dec) 200 ms and LAV to 50 ms.
    I restarted MP after each of the changes and recognized the long channel changes.

    The issue hasn't been solved. Max ~40 ms work well.

    I attached a TsReader.log with the 1500 / 200 setting. It seems to be slightly different than the first one.

    btw: when connecting to the TV-service of this computer with my laptop, I can set an audio delay up to ~350 ms with no problem. Why could this be? The laptop is a really old one compared to the HTPC.
    Same MP version.

    Regards
    Eggert
     
    Last edited: July 17, 2014
  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
    OK - that points to a slightly different area of the code which is probably causing the issue.

    I'll build you a modified TsReader.ax to try.



    What this means (from the log):

    Code (Text):
    1.  
    2. [2014-07-17 22:00:04,667] [13aeef00] [23dc] - audPin : Audio to render late= -0.106
    3. [2014-07-17 22:00:04,667] [13aeef00] [23dc] - Aud/Ref : 25.567, Compensated = 25.544 ( -0.106 A/V buffers=21/46), Clk : 25.650354, SampCnt 176, Sleep 1 ms, stallPt 1.100
    4. [2014-07-17 22:00:04,817] [13aeef00] [23dc] - Aud/Ref : 25.711, Compensated = 25.688 ( -0.112 A/V buffers=22/47), Clk : 25.800354, SampCnt 177, Sleep 1 ms, stallPt 1.100
    5. [2014-07-17 22:00:04,957] [13aeef00] [23dc] - Aud/Ref : 25.855, Compensated = 25.832 ( -0.108 A/V buffers=22/49), Clk : 25.940438, SampCnt 178, Sleep 1 ms, stallPt 1.100
    6. [2014-07-17 22:00:05,097] [13aeef00] [23dc] - Aud/Ref : 25.999, Compensated = 25.976 ( -0.104 A/V buffers=21/46), Clk : 26.080417, SampCnt 179, Sleep 1 ms, stallPt 1.100
    7. [2014-07-17 22:00:05,247] [13aeef00] [23dc] - Aud/Ref : 26.143, Compensated = 26.120 ( -0.110 A/V buffers=20/44), Clk : 26.230375, SampCnt 180, Sleep 1 ms, stallPt 1.100
    8. [2014-07-17 22:00:05,387] [13aeef00] [23dc] - Aud/Ref : 26.287, Compensated = 26.264 ( -0.106 A/V buffers=22/50), Clk : 26.370375, SampCnt 181, Sleep 1 ms, stallPt 1.100
    9. [2014-07-17 22:00:05,537] [13aeef00] [23dc] - Aud/Ref : 26.431, Compensated = 26.408 ( -0.112 A/V buffers=21/47), Clk : 26.520396, SampCnt 182, Sleep 1 ms, stallPt 1.100
    10. [2014-07-17 22:00:05,677] [13aeef00] [23dc] - Aud/Ref : 26.575, Compensated = 26.552 ( -0.108 A/V buffers=20/44), Clk : 26.660354, SampCnt 183, Sleep 1 ms, stallPt 1.100
    11. [2014-07-17 22:00:05,817] [13aeef00] [23dc] - Aud/Ref : 26.719, Compensated = 26.696 ( -0.104 A/V buffers=22/53), Clk : 26.800396, SampCnt 184, Sleep 1 ms, stallPt 1.100
    12. [2014-07-17 22:00:05,967] [13aeef00] [23dc] - Aud/Ref : 26.863, Compensated = 26.840 ( -0.111 A/V buffers=21/50), Clk : 26.950521, SampCnt 185, Sleep 1 ms, stallPt 1.100
    13. [2014-07-17 22:00:06,107] [13aeef00] [23dc] - Aud/Ref : 27.007, Compensated = 26.984 ( -0.106 A/V buffers=20/45), Clk : 27.090375, SampCnt 186, Sleep 1 ms, stallPt 1.100
    14. [2014-07-17 22:00:06,164] [13aeef00] [1dac] - Pause 321 mS renderer clock to match provider/RTSP clock, A/V = 19/45
    15. [2014-07-17 22:00:06,165] [13aeef00] [1dac] - CTsReaderFilter::Pause() - IsTimeShifting = 1 - state = 2
    16. [2014-07-17 22:00:06,165] [13aeef00] [1dac] - CTsReaderFilter::Pause() - END - state = 1
    17. [2014-07-17 22:00:06,486] [13aeef00] [1dac] - CTsReaderFilter::Run(177675.60) state 1 seeking 0
    18. [2014-07-17 22:00:06,486] [13aeef00] [1dac] - Run() - Elapsed time from pause to Audio/Video ( total zapping time ) : 321 mS
    19. [2014-07-17 22:00:06,486] [13aeef00] [1dac] - CTsReaderFilter::Run(177675.60) state 2 -->done
    20.  
    ....is that TsReader is detecting that the audio samples on it's output pin are late (relative to the renderer clock), so it assumes that there is a data starvation problem and attempts to correct it by pausing playback for a short time. It needs to do this sometimes to recover from stream corruption and when playback is running faster than the broadcast stream, but it's being triggered by the effect of the timestamp adjustments LAV Audio decoder is performing.
     
    • Thank You! Thank You! x 1
  7. 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
    Attached is a new version of TsReader to try - just replace the version in C:\Program Files\Team MediaPortal\MediaPortal (after making a backup copy of the original !)

    This has a new registry setting - "ExternalDelayCompInMilliSeconds". Set this to the same value (in milliseconds) as the audio delay in LAV and it should fix the problem. (Just play some TV/recording in MP to create the new reg key before you change it)

    Please let me know if it works :)
     

    Attached Files:

    • Thank You! Thank You! x 1
  8. Eggert
    • Premium Supporter

    Eggert MP Donator

    Joined:
    May 23, 2005
    Messages:
    70
    Likes Received:
    3
    Ratings:
    +4 / 0
    Brilliant!
    It works!!

    Thank you very much, I almost gave up - it was really worth asking here.

    Just to get sure:
    does it always have to be exact the same delay? Or can I use a higher value even if the LAV delay is lower without any disadvantage?
    The reason why I ask:
    I also use the Audio Renderer Changer (ARC) which is able to switch the audio output device on the fly (analog <--> digital).
    It has an option to import some registry values with every change.
    Because LAV does recognize the audio delay setting "live" (can be adjusted while playback within the registry) and the two audio devices need a slightly different audio delay value, it would be cool if your new setting would cover both values for both audio output devices without getting any disadvantage. I tried to change your new setting "live" but it will only get recognized when restarting the stream (which the ARC doesn't seem to do). Otherwise I could just add it to the registry files that ARC imports anyway for the LAV settings.

    I have made 3 requests on the forum this week of which 2 have been solved within a really short time.
    Just wanted to let you know that this great support is worth another donation.
    Thanks again.

    Eggert
     
    • Like Like x 1
  9. 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 setting is not critical - just set it to approximately the same as the highest delay you are using with LAV. The allowed values are between 0 and 999 ms.
    (What it's actually adjusting is the 'sample lateness detection' thresholds in TsReader, which are used to detect if it's running out of timeshift data and to help with recovery from signal corruptions.)
     
  10. Eggert
    • Premium Supporter

    Eggert MP Donator

    Joined:
    May 23, 2005
    Messages:
    70
    Likes Received:
    3
    Ratings:
    +4 / 0
    Would it be possible to automatically set the same value (+x) as LAV has (if using LAV) by copying the LAV registry setting?
    This would solve the problem for other users as well without searching the forums?

    [HKEY_CURRENT_USER\Software\LAV\Audio]
    "AudioDelayEnabled"=dword:00000001
    "AudioDelay"=dword:00000064

    Eggert
     
  11. 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
    I've thought about doing something like that, but I'd prefer to do something 'automatic' that would work for other decoders/renderers as well (just haven't thought of a way to do it yet ;))
     
    • Like Like x 1
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!