perin / flv4php

Automatically exported from code.google.com/p/flv4php
0 stars 0 forks source link

Simple fix to allow greater than 64k indexes #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I was running into an issue with long (3 hour) flash videos, since their 
bodylength exceeded the 
uint16 being used to store body length.  Since php doesn't have a 24bit uint, 
I'm using this as a 
workaround.  I think I'm using the php5 tree, which I understand isn't the 
focus these days, but I 
thought I'd put it out there in case anyone comes up with it.

In the section that calculate bodylength and timestamp, replace:
$out.= pack('Cn', 0, strlen($serMeta)); //assumes it's shorter than 64Kb
$out.= pack('N', 0);

with

$out .= pack('I*', strlen($serMeta) * 256);
//Timestamp   
$out.= pack('n', 0);     
$out.= pack('C', 0);

We just shift everything over 8 bits so that it's, in essence, a 24bit uint, 
and then the timestamp 
ends up eating up the other 24 bits with zeros.  

Original issue reported on code.google.com by cmcfad...@gmail.com on 24 Jan 2008 at 1:02

GoogleCodeExporter commented 9 years ago
I would have to check when i get home, i am guessing it is the same issue in 
the php
4 version? May be dumb question, but After this change do i work with short 
video's also?

Or Should there be made code to determine weather the fixed / old code should 
be used ?

-Fanno

Original comment by fan...@gmail.com on 24 Jan 2008 at 1:35

GoogleCodeExporter commented 9 years ago
It seems to still work fine with short videos in all of my testing - since we 
pack() into a 32bit int, php 
automatically takes care of padding with zeros on the big end in the case of 
shorter movies. 

Original comment by cmcfad...@gmail.com on 24 Jan 2008 at 2:18