google-code-export / haxevideo

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

Seek fails on long videos #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a longish FLV file (Say 25 mins) at 400kbps, 25fps 
2. Seek to about 20 mins in the video
3. Watch server fail

What is the expected output? What do you see instead?

Expected to get the video return, instead get a seek fail: eg:

[2008-10-23 12:34:22] Mismatch arguments for 'seek' : [ANull, ANumber(1240000)]

What version of the product are you using? On what operating system?

v1.1 os.x

Please provide any additional information below.

Problem appears to be caused by lines 71-81 in Commands.hx:

        case T.Int:
            v = Amf.number(a);
            if( v != null ) {
                // sometimes, AMF sends floats that are not ints.
                // We will assume a .001 precision here
                var i = Std.int(v * 1000 + 0.001);
                if( i % 1000 != 0 )
                    v = null;
                else
                    v = Std.int(i/1000);
            }

it appears that when v greater than a large value (approximately 110000 )
then v becomes negative (presumably an issue with the Std.in library in
Haxe/Neko?). I'm not _entirely_ sure what the above code does, but I've
hacked in the follow workaround:

            v = Amf.number(a);
            if( v != null ) {
                // sometimes, AMF sends floats that are not ints.
                // We will assume a .001 precision here
                if ( v < 1005000 ) {
                    var i = Std.int(v * 1000 + 0.001);
                    if( i % 1000 != 0 )
                        v = null;
                    else
                        v = Std.int(i/1000);
                } 
                else {
                    return v;
                }
            }

I'm sure there is probably a better solution, but this works for me. 

Original issue reported on code.google.com by doria...@gmail.com on 23 Oct 2008 at 11:42

GoogleCodeExporter commented 9 years ago
Thanks for the report, here's the way I fixed it :

if( v != null ) {
    // sometimes, AMF sends floats that are not ints.
    // We will assume a .0001 precision here
    var i = Math.round(v);
    var e = v - i;
    if( e > 1e4 || e < -1e4 )
        v = null;
    else
        v = i;
}

Could you check that it works correctly and fixes your bug ?

Original comment by ncanna...@gmail.com on 25 Oct 2008 at 9:54

GoogleCodeExporter commented 9 years ago
Yep, that works splendidly, can seek into a 3hour long FLV file with out the 
error
arrising.

Original comment by dorian.m...@gmail.com on 26 Oct 2008 at 6:37