Quote:
Originally Posted by bladess
I've been trying to use your code to extract a few Digital Red avi s myself, but it only starts to decode the file, and after 20-50 kB of data it terminates (I have avi files ranging from 5MB to 100 MB).
Did you come across this kind of a problem?
(I was compiling your code under Win with minGW and also with Visual Studio 2015 without success, and I've started to wonder if the EOF is interpreted differently here than in Linux. )
|
Indeed, this is the problem. By default, the stdio functions in Windows compilers convert "\n" to "\r\n" on write, since the latter (carriage return + linefeed) is what Windows uses to
separate lines in text files.
Of course this treatment corrupts binary files, but there is a solution: you can force binary I/O with the _setmode() function in MinGW, like so:
Code:
#include <fcntl.h>
_setmode(_fileno(stdin),_O_BINARY);
_setmode(_fileno(stdout),_O_BINARY);
See
http://www.willus.com/mingw/_binary.shtml.