comparison mencoder.c @ 5669:391931fa79a6

enabled new OSD code in -vop expand, subtitles rendering support to mencoder
author arpi
date Wed, 17 Apr 2002 21:51:18 +0000
parents 9b422f216fb5
children bf171d329546
comparison
equal deleted inserted replaced
5668:978c6f78022e 5669:391931fa79a6
146 char* passtmpfile="divx2pass.log"; 146 char* passtmpfile="divx2pass.log";
147 int pass_working=0; 147 int pass_working=0;
148 148
149 static int play_n_frames=-1; 149 static int play_n_frames=-1;
150 150
151 #include "libvo/font_load.h"
152 #include "libvo/sub.h"
153
154 // sub:
155 char *font_name=NULL;
156 float font_factor=0.75;
157 char *sub_name=NULL;
158 float sub_delay=0;
159 float sub_fps=0;
160 int sub_auto = 0;
161
162 #ifdef USE_SUB
163 static subtitle* subtitles=NULL;
164 float sub_last_pts = -303;
165 #endif
166
167
168
151 //char *out_audio_codec=NULL; // override audio codec 169 //char *out_audio_codec=NULL; // override audio codec
152 //char *out_video_codec=NULL; // override video codec 170 //char *out_video_codec=NULL; // override video codec
153 171
154 //#include "libmpeg2/mpeg2.h" 172 //#include "libmpeg2/mpeg2.h"
155 //#include "libmpeg2/mpeg2_internal.h" 173 //#include "libmpeg2/mpeg2_internal.h"
215 } 233 }
216 } 234 }
217 235
218 236
219 //--------------------------------------------------------------------------- 237 //---------------------------------------------------------------------------
220
221 void *vo_spudec=NULL;
222 238
223 int dec_audio(sh_audio_t *sh_audio,unsigned char* buffer,int total){ 239 int dec_audio(sh_audio_t *sh_audio,unsigned char* buffer,int total){
224 int size=0; 240 int size=0;
225 int eof=0; 241 int eof=0;
226 while(size<total && !eof){ 242 while(size<total && !eof){
332 gCpuCaps.cpuType,gCpuCaps.hasMMX,gCpuCaps.hasMMX2, 348 gCpuCaps.cpuType,gCpuCaps.hasMMX,gCpuCaps.hasMMX2,
333 gCpuCaps.has3DNow, gCpuCaps.has3DNowExt, 349 gCpuCaps.has3DNow, gCpuCaps.has3DNowExt,
334 gCpuCaps.hasSSE, gCpuCaps.hasSSE2); 350 gCpuCaps.hasSSE, gCpuCaps.hasSSE2);
335 #endif 351 #endif
336 352
353 // check font
354 #ifdef USE_OSD
355 if(font_name){
356 vo_font=read_font_desc(font_name,font_factor,verbose>1);
357 if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
358 } else {
359 // try default:
360 vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1);
361 if(!vo_font)
362 vo_font=read_font_desc(DATADIR"/font/font.desc",font_factor,verbose>1);
363 }
364 #endif
365
366 vo_init_osd();
367
337 // FIXME: get rid of -dvd and other tricky options and config/playtree 368 // FIXME: get rid of -dvd and other tricky options and config/playtree
338 stream2=open_stream(frameno_filename,0,&i); 369 stream2=open_stream(frameno_filename,0,&i);
339 if(stream2){ 370 if(stream2){
340 demuxer2=demux_open(stream2,DEMUXER_TYPE_AVI,-1,-1,-2); 371 demuxer2=demux_open(stream2,DEMUXER_TYPE_AVI,-1,-1,-2);
341 if(demuxer2) printf("Using pass3 control file: %s\n",frameno_filename); 372 if(demuxer2) printf("Using pass3 control file: %s\n",frameno_filename);
479 vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream->priv))->cur_pgc->palette:NULL, 510 vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream->priv))->cur_pgc->palette:NULL,
480 sh_video->disp_w, sh_video->disp_h); 511 sh_video->disp_w, sh_video->disp_h);
481 } 512 }
482 #endif 513 #endif
483 514
515 #ifdef USE_SUB
516 // after reading video params we should load subtitles because
517 // we know fps so now we can adjust subtitles time to ~6 seconds AST
518 // check .sub
519 // current_module="read_subtitles_file";
520 if(sub_name){
521 subtitles=sub_read_file(sub_name, sh_video->fps);
522 if(!subtitles) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name);
523 } else
524 if(sub_auto) { // auto load sub file ...
525 subtitles=sub_read_file( filename ? sub_filename( get_path("sub/"), filename )
526 : "default.sub", sh_video->fps );
527 }
528 #endif
529
530
484 // set up output file: 531 // set up output file:
485 muxer_f=fopen(out_filename,"wb"); 532 muxer_f=fopen(out_filename,"wb");
486 if(!muxer_f) { 533 if(!muxer_f) {
487 printf("Cannot open output file '%s'\n", out_filename); 534 printf("Cannot open output file '%s'\n", out_filename);
488 mencoder_exit(1,NULL); 535 mencoder_exit(1,NULL);
555 } 602 }
556 if(!mux_v->bih || !sh_video->vfilter){ 603 if(!mux_v->bih || !sh_video->vfilter){
557 mp_msg(MSGT_MENCODER,MSGL_FATAL,"Failed to open the encoder\n"); 604 mp_msg(MSGT_MENCODER,MSGL_FATAL,"Failed to open the encoder\n");
558 mencoder_exit(1,NULL); 605 mencoder_exit(1,NULL);
559 } 606 }
607 // append 'expand' filter, it fixes stride problems and renders osd:
608 sh_video->vfilter=vf_open_filter(sh_video->vfilter,"expand","-1:-1:-1:-1:1");
560 sh_video->vfilter=append_filters(sh_video->vfilter); 609 sh_video->vfilter=append_filters(sh_video->vfilter);
561 610
562 mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n"); 611 mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
563 // Go through the codec.conf and find the best codec... 612 // Go through the codec.conf and find the best codec...
564 sh_video->inited=0; 613 sh_video->inited=0;
1025 ); 1074 );
1026 #endif 1075 #endif
1027 } 1076 }
1028 fflush(stdout); 1077 fflush(stdout);
1029 1078
1079 #ifdef USE_SUB
1080 // find sub
1081 if(subtitles && d_video->pts>0){
1082 float pts=d_video->pts;
1083 if(sub_fps==0) sub_fps=sh_video->fps;
1084 if (pts > sub_last_pts || pts < sub_last_pts-1.0 ) {
1085 find_sub(subtitles,sub_uses_time?(100*(pts+sub_delay)):((pts+sub_delay)*sub_fps)); // FIXME! frame counter...
1086 sub_last_pts = pts;
1087 }
1088 }
1089 #endif
1090
1091 #ifdef USE_DVDREAD
1092 // DVD sub:
1093 if(vo_spudec){
1094 unsigned char* packet=NULL;
1095 int len;
1096 while((len=ds_get_packet_sub(d_dvdsub,&packet))>0){
1097 mp_msg(MSGT_MENCODER,MSGL_V,"\rDVD sub: len=%d v_pts=%5.3f s_pts=%5.3f \n",len,d_video->pts,d_dvdsub->pts);
1098 spudec_assemble(vo_spudec,packet,len,90000*d_dvdsub->pts);
1099 }
1100 spudec_heartbeat(vo_spudec,90000*d_video->pts);
1101 }
1102 #endif
1030 1103
1031 1104
1032 } // while(!eof) 1105 } // while(!eof)
1033 1106
1034 #ifdef HAVE_MP3LAME 1107 #ifdef HAVE_MP3LAME