2531
|
1
|
|
2 #define VCODEC_DIVX4 1
|
2581
|
3 #define ACODEC_VBRMP3 1
|
2531
|
4
|
|
5 #include <stdio.h>
|
|
6 #include <stdlib.h>
|
|
7 #include <string.h>
|
|
8 #include <signal.h>
|
|
9
|
|
10 #include "mp_msg.h"
|
|
11 #include "help_mp.h"
|
|
12
|
|
13 #include "codec-cfg.h"
|
|
14
|
|
15 #include "stream.h"
|
|
16 #include "demuxer.h"
|
|
17 #include "stheader.h"
|
|
18
|
|
19 #include "aviwrite.h"
|
|
20
|
|
21 #include "libvo/video_out.h"
|
|
22
|
2574
|
23 #include "dec_audio.h"
|
|
24 #include "dec_video.h"
|
|
25
|
2531
|
26 #include <encore2.h>
|
|
27
|
2571
|
28 #include "get_path.c"
|
2531
|
29
|
|
30 //--------------------------
|
|
31
|
|
32 // cache2:
|
|
33 #ifdef USE_STREAM_CACHE
|
|
34 extern int cache_fill_status;
|
|
35 #else
|
|
36 #define cache_fill_status 0
|
|
37 #endif
|
|
38
|
|
39 // AVI demuxer params:
|
|
40 static float c_total=0;
|
|
41 int delay_corrected=1;
|
|
42
|
|
43 char *audio_codec=NULL; // override audio codec
|
|
44 char *video_codec=NULL; // override video codec
|
|
45 int audio_family=-1; // override audio codec family
|
|
46 int video_family=-1; // override video codec family
|
|
47
|
|
48 // audio stream skip/resync functions requires only for seeking.
|
|
49 // (they should be implemented in the audio codec layer)
|
|
50 //void skip_audio_frame(sh_audio_t *sh_audio){}
|
|
51 //void resync_audio_stream(sh_audio_t *sh_audio){}
|
|
52
|
|
53 int verbose=5; // must be global!
|
|
54
|
|
55 double video_time_usage=0;
|
|
56 double vout_time_usage=0;
|
|
57 static double audio_time_usage=0;
|
|
58 static int total_time_usage_start=0;
|
|
59 static int benchmark=0;
|
|
60
|
|
61 int force_fps=0;
|
|
62
|
|
63 #include "libmpeg2/mpeg2.h"
|
|
64 #include "libmpeg2/mpeg2_internal.h"
|
|
65
|
|
66 static unsigned char* vo_image=NULL;
|
|
67 static unsigned char* vo_image_ptr=NULL;
|
|
68 static int vo_w,vo_h;
|
|
69
|
|
70 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h, int x0,int y0){
|
|
71 int y;
|
|
72 // printf("draw_slice %dx%d %d;%d\n",w,h,x,y);
|
|
73
|
|
74 // copy Y:
|
|
75 for(y=0;y<h;y++){
|
|
76 unsigned char* s=src[0]+stride[0]*(y0+y)+x0;
|
|
77 unsigned char* d=vo_image+vo_w*(y0+y)+x0;
|
|
78 memcpy(d,s,w);
|
|
79 }
|
|
80 x0>>=1;y0>>=1;
|
|
81 w>>=1;h>>=1;
|
|
82 // copy U:
|
|
83 for(y=0;y<h;y++){
|
2577
|
84 unsigned char* s=src[2]+stride[2]*(y0+y)+x0;
|
2531
|
85 unsigned char* d=vo_image+vo_w*vo_h+(vo_w>>1)*(y0+y)+x0;
|
|
86 memcpy(d,s,w);
|
|
87 }
|
|
88 // copy V:
|
|
89 for(y=0;y<h;y++){
|
|
90 unsigned char* s=src[1]+stride[1]*(y0+y)+x0;
|
|
91 unsigned char* d=vo_image+vo_w*vo_h+vo_w*vo_h/4+(vo_w>>1)*(y0+y)+x0;
|
|
92 memcpy(d,s,w);
|
|
93 }
|
|
94
|
|
95 }
|
|
96
|
|
97 static uint32_t draw_frame(uint8_t *src[]){
|
|
98 // printf("This function shouldn't be called - report bug!\n");
|
|
99 // later: add YUY2->YV12 conversion here!
|
|
100 vo_image_ptr=src[0];
|
|
101 }
|
|
102
|
|
103 vo_functions_t video_out;
|
|
104
|
|
105 //---------------
|
|
106
|
|
107 static int eof=0;
|
|
108
|
|
109 static void exit_sighandler(int x){
|
|
110 eof=1;
|
|
111 }
|
|
112
|
|
113 int main(int argc,char* argv[]){
|
|
114
|
|
115 stream_t* stream=NULL;
|
|
116 demuxer_t* demuxer=NULL;
|
|
117 demux_stream_t *d_audio=NULL;
|
|
118 demux_stream_t *d_video=NULL;
|
|
119 demux_stream_t *d_dvdsub=NULL;
|
|
120 sh_audio_t *sh_audio=NULL;
|
|
121 sh_video_t *sh_video=NULL;
|
|
122 int file_format=DEMUXER_TYPE_UNKNOWN;
|
|
123 int i;
|
|
124 unsigned int out_fmt;
|
|
125
|
|
126 aviwrite_t* muxer=NULL;
|
|
127 aviwrite_stream_t* mux_a=NULL;
|
|
128 aviwrite_stream_t* mux_v=NULL;
|
|
129 FILE* muxer_f=NULL;
|
|
130
|
|
131 ENC_PARAM enc_param;
|
|
132 ENC_FRAME enc_frame;
|
|
133 ENC_RESULT enc_result;
|
|
134 void* enc_handle=NULL;
|
|
135
|
2581
|
136 float audio_preload=0.3;
|
|
137
|
2531
|
138 //int out_buffer_size=0x200000;
|
|
139 //unsigned char* out_buffer=malloc(out_buffer_size);
|
|
140
|
|
141 mp_msg_init(verbose+MSGL_STATUS);
|
|
142
|
|
143 // check codec.conf
|
|
144 if(!parse_codec_cfg("etc/codecs.conf")){
|
|
145 mp_msg(MSGT_CPLAYER,MSGL_HINT,MSGTR_CopyCodecsConf);
|
|
146 exit(0); // From unknown reason a hangup occurs here :((((((
|
|
147 }
|
|
148
|
|
149 if(argc>1)
|
|
150 stream=open_stream(argv[1],0,&file_format);
|
|
151 else
|
2581
|
152 // stream=open_stream("/3d/abcug/Weird AL - Amish Paradise (MUSIC VIDEO).mpeg",0,&file_format);
|
|
153 stream=open_stream("/3d/divx/405divx_sm_v2[1].avi",0,&file_format);
|
2531
|
154 // stream=open_stream("/dev/cdrom",2,&file_format); // VCD track 2
|
|
155
|
|
156 if(!stream){
|
|
157 printf("Cannot open file/device\n");
|
|
158 exit(1);
|
|
159 }
|
|
160
|
|
161 printf("success: format: %d data: 0x%X - 0x%X\n",file_format, (int)(stream->start_pos),(int)(stream->end_pos));
|
|
162
|
|
163 stream_enable_cache(stream,2048*1024);
|
|
164
|
|
165 demuxer=demux_open(stream,file_format,-1,-1,-1);
|
|
166 if(!demuxer){
|
|
167 printf("Cannot open demuxer\n");
|
|
168 exit(1);
|
|
169 }
|
|
170
|
|
171 d_audio=demuxer->audio;
|
|
172 d_video=demuxer->video;
|
|
173 d_dvdsub=demuxer->sub;
|
|
174 sh_audio=d_audio->sh;
|
|
175 sh_video=d_video->sh;
|
|
176
|
|
177 if(!video_read_properties(sh_video)){
|
|
178 printf("Couldn't read video properties\n");
|
|
179 exit(1);
|
|
180 }
|
|
181
|
|
182 mp_msg(MSGT_CPLAYER,MSGL_INFO,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n",
|
|
183 demuxer->file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h,
|
|
184 sh_video->fps,sh_video->frametime
|
|
185 );
|
|
186
|
|
187
|
|
188 sh_video->codec=NULL;
|
|
189 if(video_family!=-1) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_TryForceVideoFmt,video_family);
|
|
190 while(1){
|
|
191 sh_video->codec=find_codec(sh_video->format,
|
|
192 sh_video->bih?((unsigned int*) &sh_video->bih->biCompression):NULL,sh_video->codec,0);
|
|
193 if(!sh_video->codec){
|
|
194 if(video_family!=-1) {
|
|
195 sh_video->codec=NULL; /* re-search */
|
|
196 mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_CantFindVfmtFallback);
|
|
197 video_family=-1;
|
|
198 continue;
|
|
199 }
|
|
200 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format);
|
|
201 mp_msg(MSGT_CPLAYER,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf"));
|
|
202 exit(1);
|
|
203 }
|
|
204 if(video_codec && strcmp(sh_video->codec->name,video_codec)) continue;
|
|
205 else if(video_family!=-1 && sh_video->codec->driver!=video_family) continue;
|
|
206 break;
|
|
207 }
|
|
208
|
|
209 mp_msg(MSGT_CPLAYER,MSGL_INFO,"%s video codec: [%s] drv:%d (%s)\n",video_codec?"Forcing":"Detected",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->info);
|
|
210
|
|
211 for(i=0;i<CODECS_MAX_OUTFMT;i++){
|
|
212 out_fmt=sh_video->codec->outfmt[i];
|
|
213 if(out_fmt==0xFFFFFFFF) continue;
|
|
214 if(out_fmt==IMGFMT_YV12) break;
|
|
215 if(out_fmt==IMGFMT_I420) break;
|
|
216 if(out_fmt==IMGFMT_IYUV) break;
|
|
217 if(out_fmt==IMGFMT_YUY2) break;
|
|
218 }
|
|
219 if(i>=CODECS_MAX_OUTFMT){
|
|
220 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_VOincompCodec);
|
|
221 exit(1); // exit_player(MSGTR_Exit_error);
|
|
222 }
|
|
223 sh_video->outfmtidx=i;
|
|
224
|
|
225 if(out_fmt==IMGFMT_YV12 || out_fmt==IMGFMT_I420 || out_fmt==IMGFMT_IYUV){
|
|
226 vo_w=sh_video->disp_w;
|
|
227 vo_h=sh_video->disp_h;
|
|
228 vo_image=malloc(vo_w*vo_h*3/2);
|
|
229 vo_image_ptr=vo_image;
|
|
230 }
|
|
231
|
2577
|
232 divx_quality=4;
|
|
233
|
2531
|
234 if(!init_video(sh_video)){
|
|
235 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CouldntInitVideoCodec);
|
|
236 exit(1);
|
|
237 }
|
|
238
|
2581
|
239
|
|
240
|
|
241 if(sh_audio){
|
|
242 // Go through the codec.conf and find the best codec...
|
|
243 sh_audio->codec=NULL;
|
|
244 if(audio_family!=-1) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_TryForceAudioFmt,audio_family);
|
|
245 while(1){
|
|
246 sh_audio->codec=find_codec(sh_audio->format,NULL,sh_audio->codec,1);
|
|
247 if(!sh_audio->codec){
|
|
248 if(audio_family!=-1) {
|
|
249 sh_audio->codec=NULL; /* re-search */
|
|
250 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantFindAfmtFallback);
|
|
251 audio_family=-1;
|
|
252 continue;
|
|
253 }
|
|
254 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantFindAudioCodec,sh_audio->format);
|
|
255 mp_msg(MSGT_CPLAYER,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf"));
|
|
256 sh_audio=d_audio->sh=NULL;
|
|
257 break;
|
|
258 }
|
|
259 if(audio_codec && strcmp(sh_audio->codec->name,audio_codec)) continue;
|
|
260 else if(audio_family!=-1 && sh_audio->codec->driver!=audio_family) continue;
|
|
261 mp_msg(MSGT_CPLAYER,MSGL_INFO,"%s audio codec: [%s] drv:%d (%s)\n",audio_codec?"Forcing":"Detected",sh_audio->codec->name,sh_audio->codec->driver,sh_audio->codec->info);
|
|
262 break;
|
|
263 }
|
|
264 }
|
|
265
|
|
266 if(sh_audio){
|
|
267 mp_msg(MSGT_CPLAYER,MSGL_V,"Initializing audio codec...\n");
|
|
268 if(!init_audio(sh_audio)){
|
|
269 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CouldntInitAudioCodec);
|
|
270 sh_audio=d_audio->sh=NULL;
|
|
271 } else {
|
|
272 mp_msg(MSGT_CPLAYER,MSGL_INFO,"AUDIO: srate=%d chans=%d bps=%d sfmt=0x%X ratio: %d->%d\n",sh_audio->samplerate,sh_audio->channels,sh_audio->samplesize,
|
|
273 sh_audio->sample_format,sh_audio->i_bps,sh_audio->o_bps);
|
|
274 }
|
|
275 }
|
|
276
|
|
277
|
|
278
|
2531
|
279 // set up video encoder:
|
|
280 video_out.draw_slice=draw_slice;
|
|
281 video_out.draw_frame=draw_frame;
|
|
282
|
|
283 // set up output file:
|
|
284 muxer_f=fopen("test.avi","wb");
|
|
285 muxer=aviwrite_new_muxer();
|
2581
|
286
|
|
287 // ============= VIDEO ===============
|
|
288
|
2531
|
289 mux_v=aviwrite_new_stream(muxer,AVIWRITE_TYPE_VIDEO);
|
|
290
|
|
291 mux_v->buffer_size=0x200000;
|
|
292 mux_v->buffer=malloc(mux_v->buffer_size);
|
|
293
|
|
294 mux_v->source=sh_video;
|
|
295
|
|
296 mux_v->h.dwSampleSize=0; // VBR
|
|
297 mux_v->h.dwScale=10000;
|
|
298 mux_v->h.dwRate=mux_v->h.dwScale*sh_video->fps;
|
|
299
|
2574
|
300 mux_v->codec=VCODEC_DIVX4; // 0=streamcopy
|
|
301
|
2531
|
302 switch(mux_v->codec){
|
|
303 case 0:
|
|
304 mux_v->bih=sh_video->bih;
|
|
305 break;
|
|
306 case VCODEC_DIVX4:
|
|
307 mux_v->bih=malloc(sizeof(BITMAPINFOHEADER));
|
|
308 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER);
|
|
309 mux_v->bih->biWidth=sh_video->disp_w;
|
|
310 mux_v->bih->biHeight=sh_video->disp_h;
|
|
311 mux_v->bih->biPlanes=0;
|
|
312 mux_v->bih->biBitCount=24;
|
|
313 mux_v->bih->biCompression=mmioFOURCC('d','i','v','x');
|
|
314 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8);
|
|
315 break;
|
|
316 }
|
|
317
|
2581
|
318 // ============= AUDIO ===============
|
|
319 if(sh_audio){
|
|
320
|
|
321 mux_a=aviwrite_new_stream(muxer,AVIWRITE_TYPE_AUDIO);
|
|
322
|
|
323 mux_a->buffer_size=0x100000; //16384;
|
|
324 mux_a->buffer=malloc(mux_a->buffer_size);
|
|
325
|
|
326 mux_a->source=sh_audio;
|
|
327
|
|
328 //mux_a->codec=ACODEC_VBRMP3; // 0=streamcopy
|
|
329
|
|
330 switch(mux_a->codec){
|
|
331 case 0:
|
|
332 mux_a->h.dwSampleSize=sh_audio->audio.dwSampleSize;
|
|
333 mux_a->h.dwScale=sh_audio->audio.dwScale;
|
|
334 mux_a->h.dwRate=sh_audio->audio.dwRate;
|
|
335 mux_a->wf=sh_audio->wf;
|
|
336 break;
|
|
337 case ACODEC_VBRMP3:
|
|
338 mux_a->h.dwSampleSize=0; // VBR
|
|
339 mux_a->h.dwScale=4608;
|
|
340 mux_a->h.dwRate=sh_audio->samplerate;
|
|
341 mux_a->wf=malloc(sizeof(WAVEFORMATEX));
|
|
342 mux_a->wf->wFormatTag=0x55; // MP3
|
|
343 mux_a->wf->nChannels=sh_audio->channels;
|
|
344 mux_a->wf->nSamplesPerSec=sh_audio->samplerate;
|
|
345 mux_a->wf->nAvgBytesPerSec=0;
|
|
346 mux_a->wf->nBlockAlign=1;
|
|
347 mux_a->wf->wBitsPerSample=16;
|
|
348 mux_a->wf->cbSize=0; // FIXME for l3codeca.acm
|
|
349 break;
|
|
350 }
|
|
351 }
|
|
352
|
2531
|
353 aviwrite_write_header(muxer,muxer_f);
|
|
354
|
|
355 switch(mux_v->codec){
|
|
356 case 0:
|
|
357 break;
|
|
358 case VCODEC_DIVX4:
|
|
359 // init divx4linux:
|
|
360 enc_param.x_dim=sh_video->disp_w;
|
|
361 enc_param.y_dim=sh_video->disp_h;
|
|
362 enc_param.framerate=sh_video->fps;
|
2577
|
363 enc_param.bitrate=1800000;
|
2531
|
364 enc_param.rc_period=0;
|
|
365 enc_param.rc_reaction_period=0;
|
|
366 enc_param.rc_reaction_ratio=0;
|
|
367 enc_param.max_quantizer=0;
|
|
368 enc_param.min_quantizer=0;
|
|
369 enc_param.max_key_interval=0;
|
|
370 enc_param.use_bidirect=0;
|
|
371 enc_param.deinterlace=0;
|
|
372 enc_param.quality=5; // the quality of compression ( 1 - fastest, 5 - best )
|
|
373 enc_param.obmc=0;
|
|
374 enc_param.handle=NULL;
|
|
375 encore(NULL,ENC_OPT_INIT,&enc_param,NULL);
|
|
376 enc_handle=enc_param.handle;
|
|
377 break;
|
|
378 }
|
|
379
|
|
380 signal(SIGINT,exit_sighandler); // Interrupt from keyboard
|
|
381 signal(SIGQUIT,exit_sighandler); // Quit from keyboard
|
|
382 signal(SIGTERM,exit_sighandler); // kill
|
|
383
|
|
384 while(!eof){
|
|
385
|
2571
|
386 float frame_time=0;
|
2531
|
387 int blit_frame=0;
|
|
388 float a_pts=0;
|
|
389 float v_pts=0;
|
2574
|
390 unsigned char* start=NULL;
|
|
391 int in_size;
|
2531
|
392
|
2581
|
393 if(sh_audio){
|
|
394 // get audio:
|
|
395 if(mux_a->timer-audio_preload<mux_v->timer){
|
|
396 // copy 0.5 sec of audio
|
|
397 int len;
|
|
398 if(mux_a->h.dwSampleSize){
|
|
399 // CBR
|
|
400 len=sh_audio->i_bps/2;
|
|
401 len/=mux_a->h.dwSampleSize;if(len<1) len=1;
|
|
402 len*=mux_a->h.dwSampleSize;
|
|
403 // printf("%d -> ",len);
|
|
404 len=demux_read_data(sh_audio->ds,mux_a->buffer,len);
|
|
405 // printf("%d \n",len);
|
|
406 } else {
|
|
407 // VBR
|
|
408 printf("not yet implemented!\n");
|
|
409 }
|
|
410 if(len>0) aviwrite_write_chunk(muxer,mux_a,muxer_f,len,0);
|
|
411 }
|
|
412 }
|
|
413
|
|
414 // get video frame!
|
|
415 in_size=video_read_frame(sh_video,&frame_time,&start,force_fps);
|
|
416 if(in_size<0){ eof=1; break; }
|
2574
|
417
|
2531
|
418 sh_video->timer+=frame_time;
|
|
419
|
|
420 if(pts_from_bps){
|
|
421 unsigned int samples=(sh_audio->audio.dwSampleSize)?
|
|
422 ((ds_tell(d_audio)-sh_audio->a_in_buffer_len)/sh_audio->audio.dwSampleSize) :
|
|
423 (d_audio->pack_no); // <- used for VBR audio
|
|
424 a_pts=samples*(float)sh_audio->audio.dwScale/(float)sh_audio->audio.dwRate;
|
|
425 delay_corrected=1;
|
|
426 } else {
|
|
427 // PTS = (last timestamp) + (bytes after last timestamp)/(bytes per sec)
|
|
428 a_pts=d_audio->pts;
|
|
429 if(!delay_corrected) if(a_pts) delay_corrected=1;
|
|
430 //printf("*** %5.3f ***\n",a_pts);
|
|
431 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
|
|
432 }
|
|
433 v_pts=d_video->pts;
|
|
434
|
|
435 mp_msg(MSGT_AVSYNC,MSGL_STATUS,"A:%6.1f V:%6.1f A-V:%7.3f ct:%7.3f %3d/%3d %2d%% %2d%% %4.1f%% %d%%\r",
|
|
436 a_pts,v_pts,a_pts-v_pts,c_total,
|
|
437 (int)sh_video->num_frames,(int)sh_video->num_frames_decoded,
|
|
438 (sh_video->timer>0.5)?(int)(100.0*video_time_usage/(double)sh_video->timer):0,
|
|
439 (sh_video->timer>0.5)?(int)(100.0*vout_time_usage/(double)sh_video->timer):0,
|
|
440 (sh_video->timer>0.5)?(100.0*audio_time_usage/(double)sh_video->timer):0
|
|
441 ,cache_fill_status
|
|
442 );
|
|
443 fflush(stdout);
|
|
444
|
2574
|
445 // if(!blit_frame) continue;
|
2531
|
446
|
|
447 switch(mux_v->codec){
|
2574
|
448 case 0:
|
|
449 mux_v->buffer=start;
|
|
450 aviwrite_write_chunk(muxer,mux_v,muxer_f,in_size,(sh_video->ds->flags&1)?0x10:0);
|
|
451 break;
|
2531
|
452 case VCODEC_DIVX4:
|
2574
|
453 blit_frame=decode_video(&video_out,sh_video,start,in_size,0);
|
|
454 if(!blit_frame){
|
|
455 // empty.
|
|
456 aviwrite_write_chunk(muxer,mux_v,muxer_f,0,0);
|
|
457 break;
|
|
458 }
|
2531
|
459 enc_frame.image=vo_image_ptr;
|
|
460 enc_frame.bitstream=mux_v->buffer;
|
|
461 enc_frame.length=mux_v->buffer_size;
|
|
462 switch(out_fmt){
|
|
463 case IMGFMT_YV12: enc_frame.colorspace=ENC_CSP_YV12; break;
|
|
464 case IMGFMT_IYUV:
|
|
465 case IMGFMT_I420: enc_frame.colorspace=ENC_CSP_I420; break;
|
|
466 case IMGFMT_YUY2: enc_frame.colorspace=ENC_CSP_YUY2; break;
|
|
467 case IMGFMT_UYVY: enc_frame.colorspace=ENC_CSP_UYVY; break;
|
|
468 case IMGFMT_RGB24:
|
|
469 case IMGFMT_BGR24:
|
|
470 enc_frame.colorspace=ENC_CSP_RGB24; break;
|
|
471 }
|
|
472 enc_frame.quant=0;
|
|
473 enc_frame.intra=0;
|
|
474 enc_frame.mvs=NULL;
|
|
475 // printf("encoding...\n");
|
|
476 encore(enc_handle,ENC_OPT_ENCODE,&enc_frame,&enc_result);
|
|
477 // printf(" len=%d key:%d qualt:%d \n",enc_frame.length,enc_result.is_key_frame,enc_result.quantizer);
|
|
478 aviwrite_write_chunk(muxer,mux_v,muxer_f,enc_frame.length,enc_result.is_key_frame?0x10:0);
|
|
479 break;
|
|
480 }
|
|
481
|
|
482
|
|
483 } // while(!eof)
|
|
484
|
|
485 aviwrite_write_index(muxer,muxer_f);
|
|
486 fseek(muxer_f,0,SEEK_SET);
|
|
487 aviwrite_write_header(muxer,muxer_f); // update header
|
|
488 fclose(muxer_f);
|
|
489
|
|
490 }
|