[Live-devel] patch for AVIFileSink.cpp

Victor V. Vinokurov victor at dialog.su
Thu Aug 10 03:22:26 PDT 2017


Good day!

I have made some changes to AVIFileSink.cpp for correct index chunk.
After these changes avi file with MJPEG data is opened correctly in VLC 
without message that index is corrupted.

Unfortunately at this moment I have no time to test my patch with other 
video data rather then MJPEG and test other players rather then VLC. But 
I hope that my patch will be useful for other people maybe with some 
additional changes to support non-MJPEG frames.

-- 
Best Regards!
---
Victor V. Vinokurov
LAIN LLC Programmer
http://dialog-nibelung.ru
-------------- next part --------------
--- AVIFileSink.cpp.orig	2017-07-18 09:40:15.000000000 +0300
+++ AVIFileSink.cpp	2017-08-10 13:06:42.875924000 +0300
@@ -25,6 +25,11 @@
 
 #define fourChar(x,y,z,w) ( ((w)<<24)|((z)<<16)|((y)<<8)|(x) )/*little-endian*/
 
+#define AVIIF_LIST		0x00000001
+#define AVIIF_KEYFRAME		0x00000010
+#define AVIIF_NO_TIME		0x00000100
+#define AVIIF_COMPRESSOR	0x0FFF0000
+
 ////////// AVISubsessionIOState ///////////
 // A structure used to represent the I/O state of each input 'subsession':
 
@@ -365,7 +370,7 @@
     addWord(indexRecord->size());
   }
 
-  fRIFFSizeValue += fNumBytesWritten;
+  fRIFFSizeValue += fNumBytesWritten + fNumIndexRecords*4*4 - 4;
   setWord(fRIFFSizePosition, fRIFFSizeValue);
 
   setWord(fAVIHMaxBytesPerSecondPosition, maxBytesPerSecond);
@@ -531,9 +536,9 @@
   // Add an index record for this frame:
   AVIIndexRecord* newIndexRecord
     = new AVIIndexRecord(fAVISubsessionTag, // chunk id
-			 frameSource[0] == 0x67 ? 0x10 : 0, // flags
-			 fOurSink.fMoviSizePosition + 8 + fOurSink.fNumBytesWritten, // offset (note: 8 == size + 'movi')
-			 frameSize + 4); // size
+			 AVIIF_KEYFRAME, // flags
+			 4 + fOurSink.fNumBytesWritten, // offset (note: 4 == 'movi')
+			 frameSize); // size
   fOurSink.addIndexRecord(newIndexRecord);
 
   // Write the data into the file:


More information about the live-devel mailing list