I've got an application (app1.exe) that generates mpeg4 frames using ffmpeg libraries, and I want to dump these frames to another application reading from stdin.
The easiest way to connect them is via a file, and this works, but now I want to use pipes.
So in app1.exe I have
fwrite(pkt.data, 1, pkt.size, (FILE*) f ); // for each frame
which creates a test.m4v file, works OK, but when I change it to
fwrite(pkt.data, 1, pkt.size, stdout ); // for each frame
and then dump it to a file app1.exe > test.m4v the file is generated correctly, but the content is corrupted:
Generated using FILE:

Generated using STDOUT:

My first thought was to check if the application generated any stdout other than the frames, but it doesn't, checked using the FILE version and dumping stdout via app1.exe>text.txt, but the file is empty. The only "outs" are stderrs, but they only occurr when the application exits.
Opening the resulting test.m4v for both versions with notepad++ shows pretty similar data, I would even say the same in both.
So my question is, what is the difference between writing to FILE and dumping stdout to file?