[Approved] Fix for stuttering/corrupted streaming of live tv (1 Viewer)

disaster123

MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for stuttering/corrupted streaming of live tv

    sorry there was a mistake in the patch and binaries - now the correct ones are up.
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    Re: AW: Fix for stuttering/corrupted streaming of live tv

    @miroslav22
    I was able to fix my stuttering with some more modifications to your patch. I would like to present a patch on top of your patch.

    Some comments on that patch - althou I haven't been working with the live tv side over a year at least (so there might be some wrong assumptions as well).

    Code:
    -  m_videoPid=pid;
    +  if (m_videoPid != pid) {
    +    m_startPcr.Reset();
    +    m_videoPid=pid;
    +  }

    During live tv TsWriter keeps the video PID always same by patching the PMT. Why was this change required? Also if the video PID would change wouldn't that new behavior cause faulty information about the timeshifting buffer duration? Wouldn't it cause the duration of the "previous" PID lifetime caused to be lost?

    Also { is not on correct line :)

    Code:
    +  ::SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);

    Thread priority shouldn't be changed above normal in any other component than in the renderers. This can introduce stuttering / dropped frames when OS scheduling changes to favor the source filter. Also I think this is not solving any real issue (it cannot help network / file system that should be the bottleneck in the SMB cases) so it is placebo or some really odd issue that it solves in the environment itself.

    This is for both, TsReader and TsWriter. Generally messing with priorities is not a good idea.

    Code:
    -  while (!ThreadIsStopping(1000)) ;
    +  while (!ThreadIsStopping(1500)) ;

    Isn't this causing the duration information to jump with 2 second leaps in MP GUI side?

    Code:
    +  if (!DeviceIoControl(m_hFile, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &cch, NULL))

    Not sure if this helps at all. All it does is that it wont create a physical file that big as required in the first place. It will grow the file allocation on the fly. It shouldn't be any faster to create a file this way. Sparse files are ment to be used as a large data storages where most of the file is left empty (makes developing the code easier when you can have continuos file addresses for data that has "holes" in it. TS buffer wont have "holes" ever.)

    It could be even slower to use sparse file since it is more complex from the file system point of view. Hard to say, should know more about the NTFS inside workings :)

    Code:
    fprintf(fp,"%02.2d-%02.2d-%04.4d %02.2d:%02.2d:%02.2d.%02.2d [%x]%s\n",

    To be a bit more consistent with other filters loggins the thread ID should be logged firts.

    Generally I dont like the proposed changes since they have possible side effects on RTSP and single seat use cases. We need to remember that SMB is not and has not ever been officially supported by MP. We cannot make any changes that can even have possible side effects on the currently supported cases.
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for stuttering/corrupted streaming of live tv

    tourettes
    thanks for you suggestions. You're completely right but as long as rtsp has the bug that it hangs on channel changes when the audio or video format changes - how shoud the users use rtsp? It is def. not usable at the moment as long as you're watching HD and SD and have different audio formats.

    I'm not quite sure which changes of my patch are def. needed to get rid of it - i just wanted to give an idea what it could be for someone who is more familiar with the code. I will try to reduce the code to the parts where i expect it is really relevant.

    - m_videoPid=pid;
    + if (m_videoPid != pid) {
    + m_startPcr.Reset();
    + m_videoPid=pid;
    + }

    During live tv TsWriter keeps the video PID always same by patching the PMT. Why was this change required? Also if the video PID would change wouldn't that new behavior cause faulty information about the timeshifting buffer duration? Wouldn't it cause the duration of the "previous" PID lifetime caused to be lost?
    I'm not 100% sure if it is required but as i'm now keeping the m_startPcr instead of getting it from the beginning every second and the tsreader code is setting the m_videoPid every second again - i thought i should reset the m_startPcr if the m_videoPid is changed.

    tourettes
    regarding logging that's the same layout like tsreader does
     

    naich

    MP Donator
  • Premium Supporter
  • August 6, 2007
    529
    25
    Home Country
    Germany Germany
    Hi Miroslav!

    Is your patch (V3 1.2 beta SVN) also working with actual SVN builds (27336)?

    without your patch I've a little bit of stuttering and sometimes artefacts while watching HD channels .

    cu
     

    romuz

    Retired Team Member
  • Premium Supporter
  • July 26, 2008
    1,045
    250
    Moskau
    Home Country
    Russian Federation Russian Federation
    Hi disaster123!
    After quick test of your patch im getting this
    30-01-2011 14:31:21.961 [980]CDiskRecorder::Flush() - Throttle to 15416 bytes
    30-01-2011 14:31:22.23 [980]CDiskRecorder::Flush() - Throttle to 32336 bytes (max)
    30-01-2011 14:33:17.775 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 14:35:58.190 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 14:38:26.515 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 14:41:42.997 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 14:44:51.507 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 14:48:12.326 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 14:51:10.197 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 14:54:11.735 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 14:57:27.327 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 15:00:42.78 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 15:03:21.603 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 15:06:39.677 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 15:09:51.806 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 15:12:39.85 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 15:15:47.377 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 15:18:44.265 [980]DeviceIoControl: Couldn't set sparse - working without sparse
    30-01-2011 15:21:59.375 [980]DeviceIoControl: Couldn't set sparse - working without sparse

    but my issues with unc timeshifting and original v3 patch seems are gone... continuing test.
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for stuttering/corrupted streaming of live tv

    I think you are on xp? This is ok then. I will release another version today or tomorrow which will rescpect tourettes comments and will again lower the i/o. In my internal testing it runs very well bit need further investigation.
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for stuttering/corrupted streaming of live tv

    strange never seen that sparse isn't available in win7. Do you have NTFS filesystem? But at least my new version won't use sparse anymore - so you can just ignore it and wait for an update.
     

    Users who are viewing this thread

    Top Bottom