Index: rtmpdump.cpp
===================================================================
--- rtmpdump.cpp	(revision 20)
+++ rtmpdump.cpp	(working copy)
@@ -28,6 +28,7 @@
 
 #ifdef WIN32
 #include <winsock.h>
+#include <io.h>
 #endif
 
 #include "rtmp.h"
@@ -45,6 +46,20 @@
 #define RD_FAILED		1
 #define RD_INCOMPLETE		2
 
+/*
+ * Set set stdout to binary mode on MinGW-Win32 env. Otherwise LR
+ * (0x0a) would be translated to CRLR (0x0d0a) and result would be
+ * corrupted video stream). On other platforms, fileObj is returned
+ * unmodified.
+ */
+FILE* SetFileToBinaryMode(FILE* fileObj)
+{
+#ifdef WIN32
+    setmode(fileno(fileObj), O_BINARY);
+#endif
+    return fileObj;
+}
+
 // starts sockets
 bool InitSockets() 
 {
@@ -1219,7 +1234,7 @@
 
 	if (!file) {
 		if(bStdoutMode)
-			file = stdout;
+			file = SetFileToBinaryMode(stdout);
 		else
 		{
 			file = fopen(flvFile, "w+b");
