/* show QuickTime .mov file structure (C) 2001. by A'rpi/ESP-team * various hacks by alex@naxine.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /* Blocks: 4bytes atom_size 4bytes atom_type (name) ... By older files, mdat is at the beginning, and moov follows it later, by newer files, moov is at the begininng. Fontosabb typeok: trak: track: ezeken belul van egy-egy stream (video/audio) tkhd: track header: fps (video esten picture size is itt van) vmhd: video media handler (video stream informaciok) smhd: sound media handler (audio stream informaciok) */ #include #include #undef NO_SPECIAL static char *atom2human_type(int type) { switch (type) { case 0x766F6F6D: return "Information sections"; /* moov */ case 0x6468766D: return "Movie header"; /* mvhd */ case 0x6169646D: return "Media stream"; /* mdia */ case 0x64686D76: return "Video media header"; /* vmhd */ case 0x64686D73: return "Sound media header"; /* smhd */ case 0x6468646D: return "Media header"; /* mdhd */ case 0x666E696D: return "Media information"; /* minf */ case 0x726C6468: return "Handler reference"; /* hdlr */ case 0x6B617274: return "New track (stream)"; /* trak */ case 0x75716D72: return "rmqu"; case 0x65657266: return "free"; case 0x64686B74: return "Track header"; /* tkhd */ case 0x61746475: return "User data"; /* udta */ case 0x7461646D: return "Movie data"; /* mdat */ case 0x6C627473: return "Sample information table"; /* stbl */ case 0x64737473: return "Sample description"; /* stsd */ case 0x6F637473: return "Chunk offset table"; /* stco */ case 0x73747473: return "Sample time table"; /* stts */ case 0x63737473: return "Sample->Chunk mapping table"; /* stsc */ case 0x7A737473: return "Sample size table"; /* stsz */ } return "unknown"; } #define S_NONE 0 #define S_AUDIO 1 #define S_VIDEO 2 int stream = S_NONE; int v_stream = 0; int a_stream = 0; static unsigned int read_dword(FILE *f){ unsigned char atom_size_b[4]; if(fread(&atom_size_b,4,1,f)<=0) return -1; return (atom_size_b[0]<<24)|(atom_size_b[1]<<16)|(atom_size_b[2]<<8)|atom_size_b[3]; } static void video_stream_info(FILE *f, int len) { int orig_pos = ftell(f); unsigned char data[len-8]; int i; // char codec[len-8]; len -= 8; for (i=0; iS table size :%d\n",len); for(i=0;iC table size :%d\n",len); for(i=0;iChunk mapping table case 0x7A737473: // stsz Sample size table case 0x746f6e70: // pnot case 0x54434950: // PICT case 0x70797466: break; default: lschunks(f,level+1,pos+atom_size); } #else switch(atom_type){ case 0x766F6F6D: // moov case 0x61726D72: // rmra case 0x61646D72: // rmda lschunks(f,level+1,pos+atom_size); } #endif fseek(f,pos+atom_size,SEEK_SET); } } int main(int argc,char* argv[]) { FILE *f; if ((f = fopen(argc>1?argv[1]:"Akira.mov","rb")) == NULL) return 1; printf("%.8s %.4s (%.8s) %5s [%s]\n\n", "position", "atom", "atomtype", "len", "human readable atom name"); lschunks(f, 0, 0); printf("\nSummary: streams: %d video/%d audio\n", v_stream, a_stream); return 0; }