Perhaps you should review the documentation for this function. It states that the function will return a HRESULT.
If you check out the directShow
error codes[
^], you can see that from VFW_E_INVALIDMEDIATYPE onwards, the most significant nibble (most significant hex digit) is 8 - this implies that the most significant bit is set.
When negative integers are represented in computers, it is done by setting the most significant bit.
An example may be seen here:
Code
HRESULT num = 0x80040200; printf("Num = %d\n", num);
printf("Num = %u\n", num);
printf("Num = 0x%X\n", num);
Output
Num = -2147220992
Num = 2147746304
Num = 0x80040200
So to sum up, what I'm getting at is that binary data may be interpreted in different ways. Above, I've interpreted it as both signed and unsigned (%d) and (%u) in the last line I've chosen to display in (uppercase) hexadecimal format (%X).
The point is, you're not actually getting a negative fame length - you're getting an error code which you are then interpreting as a signed int. I'd suggest error checking and a look at the error codes page I linked.