K-S-V / Scripts

Collection of my scripts
GNU General Public License v3.0
635 stars 226 forks source link

Verify failure with SyFy in AdobeHDS #6

Closed patrickslin closed 11 years ago

patrickslin commented 11 years ago

It looks like SyFy has changed a couple of things, which breaks download and verification.

The first is that they have switched to chunked transfer encoding for fragments, so the content length is no longer sent as part of the response. I don't know if this specifically causes a problem with the script.

The second is that the fragments downloaded no longer contain an explicit boxsize for the 'mdat' box. It now looks to have a boxsize of zero, so the 'mdat' box should extend until the end of the file.

This should fix the issue:

  function ReadBoxHeader($str, &$pos, &$boxType, &$boxSize)
    {
      if (!isset($pos))
          $pos = 0;
      $boxSize = ReadInt32($str, $pos);
      $boxType = substr($str, $pos + 4, 4);
      if ($boxSize == 1)
        {
          $boxSize = ReadInt64($str, $pos + 8) - 16;
          $pos += 16;
        }
      else if ($boxSize == 0)
        {
          $boxSize = strlen($str) - $pos - 8;
          $pos += 8;
        }
      else
        {
          $boxSize -= 8;
          $pos += 8;
        }
    }

-- Patrick

K-S-V commented 11 years ago

boxSize was already being ignored in case of live streams. i have made changes in VerifyFragment function to fix it before processing. see https://github.com/K-S-V/Scripts/commit/679865bfd8b22a4c447b9b1c74e562007edb822b.

for Transfer-Encoding problem please provide the specific url you are having problem with.

patrickslin commented 11 years ago

The chunked transfer encoding may not be a problem per se. I just mentioned it because I noticed that the header was returned when downloading fragments last week from Syfy, Bravo and USA. I don't know if this was an intermittent problem or just that some servers in their cluster was behaving differently than most of the others.

A quick look at it just now showed that the content length was getting returned. I'll post back if I see this problem again and there is an issue. Cheers.