Mercurial > mplayer.hg
comparison TOOLS/vivodump.c @ 2672:1ff47e4ff44d
works! copy video steram to .avi file playable with ivvideo.dll
author | arpi |
---|---|
date | Sun, 04 Nov 2001 04:55:44 +0000 |
parents | a17fcca740ff |
children | d0f26c572633 |
comparison
equal
deleted
inserted
replaced
2671:555cb027c7a7 | 2672:1ff47e4ff44d |
---|---|
130 int main(){ | 130 int main(){ |
131 int c; | 131 int c; |
132 unsigned int head=-1; | 132 unsigned int head=-1; |
133 int pos=0; | 133 int pos=0; |
134 int frames=0; | 134 int frames=0; |
135 FILE *f=fopen("coap.viv","rb"); | 135 FILE *f=fopen("bion1vd-28.viv","rb"); |
136 FILE *f2=fopen("coap.avi","wb"); | 136 FILE *f2=fopen("bion1vd-28.avi","wb"); |
137 aviwrite_t* avi=aviwrite_new_muxer(); | 137 aviwrite_t* avi=aviwrite_new_muxer(); |
138 aviwrite_stream_t* mux=aviwrite_new_stream(avi,AVIWRITE_TYPE_VIDEO); | 138 aviwrite_stream_t* mux=aviwrite_new_stream(avi,AVIWRITE_TYPE_VIDEO); |
139 //unsigned char* buffer=malloc(0x200000); | |
139 int i; | 140 int i; |
140 | 141 int v_id=0; |
141 while((c=fgetc(f))>=0){ | 142 int flag=0; |
142 ++pos; | |
143 head=(head<<8)|c; | |
144 if((head&0xFFFFFF)==0x80){ | |
145 unsigned char buf[33]; | |
146 int i; | |
147 buf[0]=buf[1]=0; buf[2]=0x80; | |
148 printf("%08X: 00 00 80",pos-3); | |
149 postable[frames++]=pos-3; | |
150 for(i=0;i<8;i++){ | |
151 c=fgetc(f);++pos; | |
152 printf(" %02X",c); | |
153 buf[3+i]=c; | |
154 } | |
155 printf("\n"); | |
156 h263_decode_picture_header(buf); | |
157 } | |
158 } | |
159 postable[frames]=pos; | |
160 printf("%d frames\n",frames); | |
161 | 143 |
162 mux->buffer_size=0x200000; | 144 mux->buffer_size=0x200000; |
163 mux->buffer=malloc(mux->buffer_size); | 145 mux->buffer=malloc(mux->buffer_size); |
164 | 146 |
165 mux->h.dwScale=1; | 147 mux->h.dwScale=1; |
166 mux->h.dwRate=10; | 148 mux->h.dwRate=10; |
167 | 149 |
168 | |
169 mux->bih=malloc(sizeof(BITMAPINFOHEADER)); | 150 mux->bih=malloc(sizeof(BITMAPINFOHEADER)); |
170 mux->bih->biSize=sizeof(BITMAPINFOHEADER); | 151 mux->bih->biSize=sizeof(BITMAPINFOHEADER); |
171 mux->bih->biWidth=width; | |
172 mux->bih->biHeight=height; | |
173 mux->bih->biPlanes=1; | 152 mux->bih->biPlanes=1; |
174 mux->bih->biBitCount=24; | 153 mux->bih->biBitCount=24; |
175 mux->bih->biCompression=0x6f766976;// 7669766f; | 154 mux->bih->biCompression=0x6f766976;// 7669766f; |
155 aviwrite_write_header(avi,f2); | |
156 | |
157 while((c=fgetc(f))>=0){ | |
158 if(!flag && c!=0x40 && c!=0x10) continue; | |
159 flag=1; | |
160 | |
161 printf("%02X\n",c); | |
162 if((c&0xF0)==0x40){ | |
163 // audio | |
164 printf("audio: %02X (24)\n",c); | |
165 for(i=0;i<24;i++) fgetc(f); | |
166 continue; | |
167 } | |
168 if(((c&0xF0)==0x10 || (c&0xF0)==0x20) && (c&0x0F)!=v_id){ | |
169 // end of frame: | |
170 printf("Frame size: %d\n",mux->buffer_len); | |
171 h263_decode_picture_header(mux->buffer); | |
172 aviwrite_write_chunk(avi,mux,f2,mux->buffer_len,0x10); | |
173 mux->buffer_len=0; | |
174 } | |
175 v_id=c&0x0F; | |
176 if((c&0xF0)==0x10){ | |
177 // 128 byte | |
178 printf("video: %02X (128)\n",c); | |
179 fread(mux->buffer+mux->buffer_len,128,1,f); | |
180 mux->buffer_len+=128; | |
181 continue; | |
182 } | |
183 if((c&0xF0)==0x20){ | |
184 // 128 byte | |
185 int len=fgetc(f); | |
186 printf("video: %02X (%d)\n",c,len); | |
187 fread(mux->buffer+mux->buffer_len,len,1,f); | |
188 mux->buffer_len+=len; | |
189 continue; | |
190 } | |
191 printf("error!\n"); | |
192 } | |
193 | |
194 mux->bih->biWidth=width; | |
195 mux->bih->biHeight=height; | |
176 mux->bih->biSizeImage=3*width*height; | 196 mux->bih->biSizeImage=3*width*height; |
177 aviwrite_write_header(avi,f2); | 197 |
178 | |
179 for(i=0;i<frames;i++){ | |
180 int len=postable[i+1]-postable[i]; | |
181 fseek(f,postable[i],SEEK_SET); | |
182 fread(mux->buffer,len,1,f); | |
183 aviwrite_write_chunk(avi,mux,f2,len,0x10); | |
184 } | |
185 aviwrite_write_index(avi,f2); | 198 aviwrite_write_index(avi,f2); |
186 fseek(f2,0,SEEK_SET); | 199 fseek(f2,0,SEEK_SET); |
187 aviwrite_write_header(avi,f2); | 200 aviwrite_write_header(avi,f2); |
188 | 201 |
189 } | 202 } |