/** Open the file with given path and read its header */ private void openAndReadHeader (String path) throws Exception, IOException { startTime = System.currentTimeMillis(); if (verbose) IJ.log("OPEN AND READ AVI FILE HEADER "+timeString()); File file = new File(path); // o p e n raFile = new RandomAccessFile(file, "r"); raFilePath = path; fileSize = raFile.length(); int fileType = readInt(); // f i l e h e a d e r if (verbose) IJ.log("File header: File type='"+fourccString(fileType)+"' (should be 'RIFF')"+timeString()); if (fileType != FOURCC_RIFF) throw new Exception("Not an AVI file."); aviSize = readInt() & SIZE_MASK; //size of AVI chunk int riffType = readInt(); if (verbose) IJ.log("File header: RIFF type='"+fourccString(riffType)+"' (should be 'AVI ')"); if (riffType != FOURCC_AVI) throw new Exception("Not an AVI file."); findFourccAndRead(FOURCC_hdrl, true, fileSize, true); startTime -= System.currentTimeMillis(); //becomes minus elapsed Time headerOK = true; }
/** Open the file with given path and read its header */ private void openAndReadHeader (String path) throws Exception, IOException { startTime = System.currentTimeMillis(); if (verbose) IJ.log("OPEN AND READ AVI FILE HEADER "+timeString()); File file = new File(path); // o p e n raFile = new RandomAccessFile(file, "r"); raFilePath = path; fileSize = raFile.length(); int fileType = readInt(); // f i l e h e a d e r if (verbose) IJ.log("File header: File type='"+fourccString(fileType)+"' (should be 'RIFF')"+timeString()); if (fileType != FOURCC_RIFF) throw new Exception("Not an AVI file."); aviSize = readInt() & SIZE_MASK; //size of AVI chunk int riffType = readInt(); if (verbose) IJ.log("File header: RIFF type='"+fourccString(riffType)+"' (should be 'AVI ')"); if (riffType != FOURCC_AVI) throw new Exception("Not an AVI file."); findFourccAndRead(FOURCC_hdrl, true, fileSize, true); startTime -= System.currentTimeMillis(); //becomes minus elapsed Time headerOK = true; }
/** Read AVIX chunks following the first RIFF AVI for large files (sequential reading frame-by-frame beyond the first chunk) **/ private void readAVIX(long endPosition) throws Exception, IOException { if (verbose) IJ.log("Trying to read AVIX"+timeString()); int riffType = readInt(); if (verbose) IJ.log("File header: RIFF type='"+fourccString(riffType)+"' (should be 'AVIX')"); if (riffType != FOURCC_AVIX) throw new Exception("Not an AVI file."); findFourccAndRead(FOURCC_movi, true, fileSize, true); //read movie data }
/** Read AVIX chunks following the first RIFF AVI for large files (sequential reading frame-by-frame beyond the first chunk) **/ private void readAVIX(long endPosition) throws Exception, IOException { if (verbose) IJ.log("Trying to read AVIX"+timeString()); int riffType = readInt(); if (verbose) IJ.log("File header: RIFF type='"+fourccString(riffType)+"' (should be 'AVIX')"); if (riffType != FOURCC_AVIX) throw new Exception("Not an AVI file."); findFourccAndRead(FOURCC_movi, true, fileSize, true); //read movie data }
frameInfos.add(new long[]{framePos+8, dwSize, (long)frameNumber*dwMicroSecPerFrame}); if (verbose) IJ.log("idx1 movie data '"+fourccString(dwChunkId)+"' "+posSizeString(framePos,dwSize)+timeString());
frameInfos.add(new long[]{framePos+8, dwSize, (long)frameNumber*dwMicroSecPerFrame}); if (verbose) IJ.log("idx1 movie data '"+fourccString(dwChunkId)+"' "+posSizeString(framePos,dwSize)+timeString());
IJ.log("MOVIE DATA "+posSizeString(endPosition-raFile.getFilePointer())+timeString()+ "\nSearching for stream "+streamNumber+": '"+ fourccString(type0xdb)+"' or '"+fourccString(type0xdc)+"' chunks"); IJ.showProgress((double)frameNumber /lastFrameToRead); if (verbose) IJ.log(frameNumber+" movie data '"+fourccString(type)+"' "+posSizeString(size)+timeString()); if (frameNumber >= firstFrame) { if (isVirtual)
IJ.log("MOVIE DATA "+posSizeString(endPosition-raFile.getFilePointer())+timeString()+ "\nSearching for stream "+streamNumber+": '"+ fourccString(type0xdb)+"' or '"+fourccString(type0xdc)+"' chunks"); IJ.showProgress((double)frameNumber /lastFrameToRead); if (verbose) IJ.log(frameNumber+" movie data '"+fourccString(type)+"' "+posSizeString(size)+timeString()); if (frameNumber >= firstFrame) { if (isVirtual)
int dwDuration = readInt(); //number of frames in ix00; ignored: not always trustworthy if (verbose) IJ.log(" indx entry: '" +fourccString(dwChunkId)+"' incl header "+posSizeString(qwOffset,dwSize)+timeString()); long nextIndxEntryPointer = raFile.getFilePointer(); frameInfos.add(new long[] {pos, dwSize, (long) frameNumber*dwMicroSecPerFrame}); if (verbose) IJ.log("movie data "+frameNumber+" '"+fourccString(dwChunkId)+"' "+posSizeString(pos,dwSize)+timeString());
int dwDuration = readInt(); //number of frames in ix00; ignored: not always trustworthy if (verbose) IJ.log(" indx entry: '" +fourccString(dwChunkId)+"' incl header "+posSizeString(qwOffset,dwSize)+timeString()); long nextIndxEntryPointer = raFile.getFilePointer(); frameInfos.add(new long[] {pos, dwSize, (long) frameNumber*dwMicroSecPerFrame}); if (verbose) IJ.log("movie data "+frameNumber+" '"+fourccString(dwChunkId)+"' "+posSizeString(pos,dwSize)+timeString());
void readAviHeader() throws Exception, IOException { //'avih' dwMicroSecPerFrame = readInt(); dwMaxBytesPerSec = readInt(); dwReserved1 = readInt(); //in newer avi formats, this is dwPaddingGranularity? dwFlags = readInt(); dwTotalFrames = readInt(); dwInitialFrames = readInt(); dwStreams = readInt(); dwSuggestedBufferSize = readInt(); dwWidth = readInt(); dwHeight = readInt(); // dwReserved[4] follows, ignored if (verbose) { IJ.log("AVI HEADER (avih):"+timeString()); IJ.log(" dwMicroSecPerFrame=" + dwMicroSecPerFrame); IJ.log(" dwMaxBytesPerSec=" + dwMaxBytesPerSec); IJ.log(" dwReserved1=" + dwReserved1); IJ.log(" dwFlags=" + dwFlags); IJ.log(" dwTotalFrames=" + dwTotalFrames); IJ.log(" dwInitialFrames=" + dwInitialFrames); IJ.log(" dwStreams=" + dwStreams); IJ.log(" dwSuggestedBufferSize=" + dwSuggestedBufferSize); IJ.log(" dwWidth=" + dwWidth); IJ.log(" dwHeight=" + dwHeight); } }
void readAviHeader() throws Exception, IOException { //'avih' dwMicroSecPerFrame = readInt(); dwMaxBytesPerSec = readInt(); dwReserved1 = readInt(); //in newer avi formats, this is dwPaddingGranularity? dwFlags = readInt(); dwTotalFrames = readInt(); dwInitialFrames = readInt(); dwStreams = readInt(); dwSuggestedBufferSize = readInt(); dwWidth = readInt(); dwHeight = readInt(); // dwReserved[4] follows, ignored if (verbose) { IJ.log("AVI HEADER (avih):"+timeString()); IJ.log(" dwMicroSecPerFrame=" + dwMicroSecPerFrame); IJ.log(" dwMaxBytesPerSec=" + dwMaxBytesPerSec); IJ.log(" dwReserved1=" + dwReserved1); IJ.log(" dwFlags=" + dwFlags); IJ.log(" dwTotalFrames=" + dwTotalFrames); IJ.log(" dwInitialFrames=" + dwInitialFrames); IJ.log(" dwStreams=" + dwStreams); IJ.log(" dwSuggestedBufferSize=" + dwSuggestedBufferSize); IJ.log(" dwWidth=" + dwWidth); IJ.log(" dwHeight=" + dwHeight); } }