comparison mencoder.c @ 13122:fcce0023bf55

printf -> mp_msg conversion, first steps patch by The Wanderer <inverseparadox@comcast.net>
author diego
date Tue, 24 Aug 2004 19:36:17 +0000
parents 4235ae5a2d60
children d198f255bee9
comparison
equal deleted inserted replaced
13121:93774d4a0c1d 13122:fcce0023bf55
271 271
272 /* FIXME */ 272 /* FIXME */
273 static void mencoder_exit(int level, char *how) 273 static void mencoder_exit(int level, char *how)
274 { 274 {
275 if (how) 275 if (how)
276 printf("Exiting... (%s)\n", how); 276 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_ExitingHow, mp_gettext(how));
277 else 277 else
278 printf("Exiting...\n"); 278 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_Exiting);
279 279
280 exit(level); 280 exit(level);
281 } 281 }
282 282
283 void parse_cfgfiles( m_config_t* conf ) 283 void parse_cfgfiles( m_config_t* conf )
285 char *conffile; 285 char *conffile;
286 if ((conffile = get_path("mencoder")) == NULL) { 286 if ((conffile = get_path("mencoder")) == NULL) {
287 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem); 287 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem);
288 } else { 288 } else {
289 if (m_config_parse_config_file(conf, conffile) < 0) 289 if (m_config_parse_config_file(conf, conffile) < 0)
290 mencoder_exit(1,"configfile error"); 290 mencoder_exit(1,MSGTR_ConfigfileError);
291 free(conffile); 291 free(conffile);
292 } 292 }
293 } 293 }
294 294
295 295
435 435
436 // FIXME: get rid of -dvd and other tricky options 436 // FIXME: get rid of -dvd and other tricky options
437 stream2=open_stream(frameno_filename,0,&i); 437 stream2=open_stream(frameno_filename,0,&i);
438 if(stream2){ 438 if(stream2){
439 demuxer2=demux_open(stream2,DEMUXER_TYPE_AVI,-1,-1,-2,NULL); 439 demuxer2=demux_open(stream2,DEMUXER_TYPE_AVI,-1,-1,-2,NULL);
440 if(demuxer2) printf(MSGTR_UsingPass3ControllFile,frameno_filename); 440 if(demuxer2) mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_UsingPass3ControllFile, frameno_filename);
441 else mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized); 441 else mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
442 } 442 }
443 443
444 mconfig = m_config_new(); 444 mconfig = m_config_new();
445 m_config_register_options(mconfig,mencoder_opts); 445 m_config_register_options(mconfig,mencoder_opts);
446 parse_cfgfiles(mconfig); 446 parse_cfgfiles(mconfig);
447 filelist = m_config_parse_me_command_line(mconfig, argc, argv); 447 filelist = m_config_parse_me_command_line(mconfig, argc, argv);
448 if(!filelist) mencoder_exit(1, "error parsing cmdline"); 448 if(!filelist) mencoder_exit(1, MSGTR_ErrorParsingCommandLine);
449 m_entry_set_options(mconfig,&filelist[0]); 449 m_entry_set_options(mconfig,&filelist[0]);
450 filename = filelist[0].name; 450 filename = filelist[0].name;
451 451
452 if(!filename){ 452 if(!filename){
453 printf(MSGTR_MissingFilename); 453 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_MissingFilename);
454 mencoder_exit(1,NULL); 454 mencoder_exit(1,NULL);
455 } 455 }
456 456
457 mp_msg_set_level(verbose+MSGL_STATUS); 457 mp_msg_set_level(verbose+MSGL_STATUS);
458 458
482 vo_init_osd(); 482 vo_init_osd();
483 483
484 stream=open_stream(filename,0,&file_format); 484 stream=open_stream(filename,0,&file_format);
485 485
486 if(!stream){ 486 if(!stream){
487 printf(MSGTR_CannotOpenFile_Device); 487 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_CannotOpenFile_Device);
488 mencoder_exit(1,NULL); 488 mencoder_exit(1,NULL);
489 } 489 }
490 490
491 printf("success: format: %d data: 0x%X - 0x%X\n",file_format, (int)(stream->start_pos),(int)(stream->end_pos)); 491 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_OpenedStream, file_format, (int)(stream->start_pos), (int)(stream->end_pos));
492 492
493 #ifdef USE_DVDREAD 493 #ifdef USE_DVDREAD
494 if(stream->type==STREAMTYPE_DVD){ 494 if(stream->type==STREAMTYPE_DVD){
495 if(audio_lang && audio_id==-1) audio_id=dvd_aid_from_lang(stream,audio_lang); 495 if(audio_lang && audio_id==-1) audio_id=dvd_aid_from_lang(stream,audio_lang);
496 if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(stream,dvdsub_lang); 496 if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(stream,dvdsub_lang);
505 505
506 //demuxer=demux_open(stream,file_format,video_id,audio_id,dvdsub_id); 506 //demuxer=demux_open(stream,file_format,video_id,audio_id,dvdsub_id);
507 demuxer=demux_open(stream,file_format,audio_id,video_id,dvdsub_id,filename); 507 demuxer=demux_open(stream,file_format,audio_id,video_id,dvdsub_id,filename);
508 if(!demuxer){ 508 if(!demuxer){
509 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized); 509 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
510 printf(MSGTR_CannotOpenDemuxer); 510 mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_CannotOpenDemuxer); //correct target/level? FIXME?
511 mencoder_exit(1,NULL); 511 mencoder_exit(1,NULL);
512 } 512 }
513 513
514 d_audio=demuxer2 ? demuxer2->audio : demuxer->audio; 514 d_audio=demuxer2 ? demuxer2->audio : demuxer->audio;
515 d_video=demuxer->video; 515 d_video=demuxer->video;
517 sh_audio=d_audio->sh; 517 sh_audio=d_audio->sh;
518 sh_video=d_video->sh; 518 sh_video=d_video->sh;
519 519
520 if(!sh_video) 520 if(!sh_video)
521 { 521 {
522 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"Video stream is mandatory!\n"); 522 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_VideoStreamRequired);
523 mencoder_exit(1,NULL); 523 mencoder_exit(1,NULL);
524 } 524 }
525 525
526 if(!video_read_properties(sh_video)){ 526 if(!video_read_properties(sh_video)){
527 printf(MSGTR_CannotReadVideoProperties); 527 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_CannotReadVideoProperties);
528 mencoder_exit(1,NULL); 528 mencoder_exit(1,NULL);
529 } 529 }
530 530
531 mp_msg(MSGT_MENCODER,MSGL_INFO,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n", 531 mp_msg(MSGT_MENCODER,MSGL_INFO,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n",
532 demuxer->file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h, 532 demuxer->file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h,
534 ); 534 );
535 535
536 if(force_fps){ 536 if(force_fps){
537 sh_video->fps=force_fps; 537 sh_video->fps=force_fps;
538 sh_video->frametime=1.0f/sh_video->fps; 538 sh_video->frametime=1.0f/sh_video->fps;
539 mp_msg(MSGT_MENCODER,MSGL_INFO,"input fps will be interpreted as %5.2f instead\n", sh_video->fps); 539 mp_msg(MSGT_MENCODER,MSGL_INFO,MSGTR_ForcingInputFPS, sh_video->fps);
540 } 540 }
541 541
542 if(sh_audio && out_file_format==MUXER_TYPE_RAWVIDEO){ 542 if(sh_audio && out_file_format==MUXER_TYPE_RAWVIDEO){
543 mp_msg(MSGT_MENCODER,MSGL_ERR,"Output file format RAWVIDEO does not support audio - disabling audio\n"); 543 mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_RawvideoDoesNotSupportAudio);
544 sh_audio=NULL; 544 sh_audio=NULL;
545 } 545 }
546 if(sh_audio && out_audio_codec<0){ 546 if(sh_audio && out_audio_codec<0){
547 if(audio_id==-2) 547 if(audio_id==-2)
548 mp_msg(MSGT_MENCODER,MSGL_ERR,"This demuxer doesn't support -nosound yet.\n"); 548 mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_DemuxerDoesntSupportNosound);
549 mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoAudioEncoderSelected); 549 mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoAudioEncoderSelected);
550 mencoder_exit(1,NULL); 550 mencoder_exit(1,NULL);
551 } 551 }
552 if(sh_video && out_video_codec<0){ 552 if(sh_video && out_video_codec<0){
553 mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoVideoEncoderSelected); 553 mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoVideoEncoderSelected);
624 spudec_set_forced_subs_only(vo_spudec,forced_subs_only); 624 spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
625 625
626 // set up output file: 626 // set up output file:
627 muxer_f=fopen(out_filename,"wb"); 627 muxer_f=fopen(out_filename,"wb");
628 if(!muxer_f) { 628 if(!muxer_f) {
629 printf(MSGTR_CannotOpenOutputFile, out_filename); 629 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_CannotOpenOutputFile, out_filename);
630 mencoder_exit(1,NULL); 630 mencoder_exit(1,NULL);
631 } 631 }
632 632
633 muxer=muxer_new_muxer(out_file_format,muxer_f); 633 muxer=muxer_new_muxer(out_file_format,muxer_f);
634 634
673 mux_v->bih->biCompression=sh_video->format; 673 mux_v->bih->biCompression=sh_video->format;
674 mux_v->bih->biPlanes=1; 674 mux_v->bih->biPlanes=1;
675 mux_v->bih->biBitCount=24; // FIXME!!! 675 mux_v->bih->biBitCount=24; // FIXME!!!
676 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8); 676 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8);
677 } 677 }
678 printf("videocodec: framecopy (%dx%d %dbpp fourcc=%x)\n", 678 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_VCodecFramecopy,
679 mux_v->bih->biWidth, mux_v->bih->biHeight, 679 mux_v->bih->biWidth, mux_v->bih->biHeight,
680 mux_v->bih->biBitCount, mux_v->bih->biCompression); 680 mux_v->bih->biBitCount, mux_v->bih->biCompression);
681 break; 681 break;
682 case VCODEC_FRAMENO: 682 case VCODEC_FRAMENO:
683 mux_v->bih=calloc(1,sizeof(BITMAPINFOHEADER)); 683 mux_v->bih=calloc(1,sizeof(BITMAPINFOHEADER));
731 /* force output fourcc to .. */ 731 /* force output fourcc to .. */
732 if ((force_fourcc != NULL) && (strlen(force_fourcc) >= 4)) 732 if ((force_fourcc != NULL) && (strlen(force_fourcc) >= 4))
733 { 733 {
734 mux_v->bih->biCompression = mmioFOURCC(force_fourcc[0], force_fourcc[1], 734 mux_v->bih->biCompression = mmioFOURCC(force_fourcc[0], force_fourcc[1],
735 force_fourcc[2], force_fourcc[3]); 735 force_fourcc[2], force_fourcc[3]);
736 printf(MSGTR_ForcingOutputFourcc, 736 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_ForcingOutputFourcc,
737 mux_v->bih->biCompression, (char *)&mux_v->bih->biCompression); 737 mux_v->bih->biCompression, (char *)&mux_v->bih->biCompression);
738 } 738 }
739 739
740 //if(demuxer->file_format!=DEMUXER_TYPE_AVI) pts_from_bps=0; // it must be 0 for mpeg/asf! 740 //if(demuxer->file_format!=DEMUXER_TYPE_AVI) pts_from_bps=0; // it must be 0 for mpeg/asf!
741 741
745 mux_a=muxer_new_stream(muxer,MUXER_TYPE_AUDIO); 745 mux_a=muxer_new_stream(muxer,MUXER_TYPE_AUDIO);
746 746
747 mux_a->buffer_size=0x100000; //16384; 747 mux_a->buffer_size=0x100000; //16384;
748 mux_a->buffer=malloc(mux_a->buffer_size); 748 mux_a->buffer=malloc(mux_a->buffer_size);
749 if (!mux_a->buffer) 749 if (!mux_a->buffer)
750 mencoder_exit(1,"memory allocation failed"); 750 mencoder_exit(1,MSGTR_MemAllocFailed);
751 751
752 mux_a->source=sh_audio; 752 mux_a->source=sh_audio;
753 753
754 mux_a->codec=out_audio_codec; 754 mux_a->codec=out_audio_codec;
755 755
776 } else { 776 } else {
777 mux_a->h.dwSampleSize=mux_a->wf->nBlockAlign; 777 mux_a->h.dwSampleSize=mux_a->wf->nBlockAlign;
778 mux_a->h.dwScale=mux_a->h.dwSampleSize; 778 mux_a->h.dwScale=mux_a->h.dwSampleSize;
779 mux_a->h.dwRate=mux_a->wf->nAvgBytesPerSec; 779 mux_a->h.dwRate=mux_a->wf->nAvgBytesPerSec;
780 } 780 }
781 printf("audiocodec: framecopy (format=%x chans=%d rate=%ld bits=%d bps=%ld sample=%ld)\n", 781 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_ACodecFramecopy,
782 mux_a->wf->wFormatTag, mux_a->wf->nChannels, mux_a->wf->nSamplesPerSec, 782 mux_a->wf->wFormatTag, mux_a->wf->nChannels, mux_a->wf->nSamplesPerSec,
783 mux_a->wf->wBitsPerSample, mux_a->wf->nAvgBytesPerSec, mux_a->h.dwSampleSize); 783 mux_a->wf->wBitsPerSample, mux_a->wf->nAvgBytesPerSec, mux_a->h.dwSampleSize);
784 break; 784 break;
785 case ACODEC_PCM: 785 case ACODEC_PCM:
786 printf("CBR PCM audio selected\n"); 786 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_CBRPCMAudioSelected);
787 mux_a->h.dwScale=1; 787 mux_a->h.dwScale=1;
788 mux_a->h.dwRate=force_srate?force_srate:sh_audio->samplerate; 788 mux_a->h.dwRate=force_srate?force_srate:sh_audio->samplerate;
789 mux_a->wf=malloc(sizeof(WAVEFORMATEX)); 789 mux_a->wf=malloc(sizeof(WAVEFORMATEX));
790 mux_a->wf->wFormatTag=0x1; // PCM 790 mux_a->wf->wFormatTag=0x1; // PCM
791 mux_a->wf->nChannels=audio_output_channels?audio_output_channels:sh_audio->channels; 791 mux_a->wf->nChannels=audio_output_channels?audio_output_channels:sh_audio->channels;
801 sh_audio->channels, sh_audio->sample_format, sh_audio->samplesize, 801 sh_audio->channels, sh_audio->sample_format, sh_audio->samplesize,
802 mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels, 802 mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels,
803 (mux_a->wf->wBitsPerSample==8)? AFMT_U8:AFMT_S16_LE, 803 (mux_a->wf->wBitsPerSample==8)? AFMT_U8:AFMT_S16_LE,
804 mux_a->wf->wBitsPerSample/8, 804 mux_a->wf->wBitsPerSample/8,
805 16384, mux_a->wf->nAvgBytesPerSec)){ 805 16384, mux_a->wf->nAvgBytesPerSec)){
806 mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format!\n"); 806 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_NoMatchingFilter);
807 } 807 }
808 break; 808 break;
809 #ifdef HAVE_MP3LAME 809 #ifdef HAVE_MP3LAME
810 case ACODEC_VBRMP3: 810 case ACODEC_VBRMP3:
811 printf("MP3 audio selected\n"); 811 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_MP3AudioSelected);
812 mux_a->h.dwSampleSize=0; // VBR 812 mux_a->h.dwSampleSize=0; // VBR
813 mux_a->h.dwRate=force_srate?force_srate:sh_audio->samplerate; 813 mux_a->h.dwRate=force_srate?force_srate:sh_audio->samplerate;
814 mux_a->h.dwScale=(mux_a->h.dwRate<32000)?576:1152; // samples/frame 814 mux_a->h.dwScale=(mux_a->h.dwRate<32000)?576:1152; // samples/frame
815 if(sizeof(MPEGLAYER3WAVEFORMAT)!=30) mp_msg(MSGT_MENCODER,MSGL_WARN,"sizeof(MPEGLAYER3WAVEFORMAT)==%d!=30, maybe broken C compiler?\n",sizeof(MPEGLAYER3WAVEFORMAT)); 815 if(sizeof(MPEGLAYER3WAVEFORMAT)!=30) mp_msg(MSGT_MENCODER,MSGL_WARN,MSGTR_MP3WaveFormatSizeNot30,sizeof(MPEGLAYER3WAVEFORMAT));
816 mux_a->wf=malloc(sizeof(MPEGLAYER3WAVEFORMAT)); // should be 30 816 mux_a->wf=malloc(sizeof(MPEGLAYER3WAVEFORMAT)); // should be 30
817 mux_a->wf->wFormatTag=0x55; // MP3 817 mux_a->wf->wFormatTag=0x55; // MP3
818 mux_a->wf->nChannels= (lame_param_mode<0) ? sh_audio->channels : 818 mux_a->wf->nChannels= (lame_param_mode<0) ? sh_audio->channels :
819 ((lame_param_mode==3) ? 1 : 2); 819 ((lame_param_mode==3) ? 1 : 2);
820 mux_a->wf->nSamplesPerSec=mux_a->h.dwRate; 820 mux_a->wf->nSamplesPerSec=mux_a->h.dwRate;
837 AFMT_S16_BE, 2, 837 AFMT_S16_BE, 2,
838 #else 838 #else
839 AFMT_S16_LE, 2, 839 AFMT_S16_LE, 2,
840 #endif 840 #endif
841 4608, mux_a->h.dwRate*mux_a->wf->nChannels*2)){ 841 4608, mux_a->h.dwRate*mux_a->wf->nChannels*2)){
842 mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format!\n"); 842 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_NoMatchingFilter);
843 } 843 }
844 break; 844 break;
845 #endif 845 #endif
846 #ifdef USE_LIBAVCODEC 846 #ifdef USE_LIBAVCODEC
847 case ACODEC_LAVC: 847 case ACODEC_LAVC:
848 if(!lavc_param_acodec) 848 if(!lavc_param_acodec)
849 { 849 {
850 mp_msg(MSGT_MENCODER, MSGL_FATAL, "Audio LAVC, Missing codec name!\n"); 850 mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_NoLavcAudioCodecName);
851 exit(1); 851 exit(1);
852 } 852 }
853 853
854 if(!avcodec_inited){ 854 if(!avcodec_inited){
855 avcodec_init(); 855 avcodec_init();
858 } 858 }
859 859
860 lavc_acodec = avcodec_find_encoder_by_name(lavc_param_acodec); 860 lavc_acodec = avcodec_find_encoder_by_name(lavc_param_acodec);
861 if (!lavc_acodec) 861 if (!lavc_acodec)
862 { 862 {
863 mp_msg(MSGT_MENCODER, MSGL_FATAL, "Audio LAVC, couldn't find encoder for codec %s\n", lavc_param_acodec); 863 mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_LavcAudioCodecNotFound, lavc_param_acodec);
864 exit(1); 864 exit(1);
865 } 865 }
866 866
867 lavc_actx = avcodec_alloc_context(); 867 lavc_actx = avcodec_alloc_context();
868 if(lavc_actx == NULL) 868 if(lavc_actx == NULL)
869 { 869 {
870 mp_msg(MSGT_MENCODER, MSGL_FATAL, "Audio LAVC, couldn't allocate context!\n"); 870 mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CouldntAllocateLavcContext);
871 exit(1); 871 exit(1);
872 } 872 }
873 873
874 if(lavc_param_atag == 0) 874 if(lavc_param_atag == 0)
875 lavc_param_atag = lavc_find_atag(lavc_param_acodec); 875 lavc_param_atag = lavc_find_atag(lavc_param_acodec);
894 lavc_actx->bit_rate = lavc_actx->sample_rate*8*blkalign/framesize; 894 lavc_actx->bit_rate = lavc_actx->sample_rate*8*blkalign/framesize;
895 } 895 }
896 896
897 if(avcodec_open(lavc_actx, lavc_acodec) < 0) 897 if(avcodec_open(lavc_actx, lavc_acodec) < 0)
898 { 898 {
899 mp_msg(MSGT_MENCODER, MSGL_FATAL, "Couldn't open codec %s, br=%d\n", lavc_param_acodec, lavc_param_abitrate); 899 mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CouldntOpenCodec, lavc_param_acodec, lavc_param_abitrate);
900 exit(1); 900 exit(1);
901 } 901 }
902 902
903 if(lavc_param_atag == 0x11) { 903 if(lavc_param_atag == 0x11) {
904 lavc_actx->block_align = 2048; 904 lavc_actx->block_align = 2048;
906 } 906 }
907 907
908 lavc_abuf = malloc(lavc_actx->frame_size * 2 * lavc_actx->channels); 908 lavc_abuf = malloc(lavc_actx->frame_size * 2 * lavc_actx->channels);
909 if(lavc_abuf == NULL) 909 if(lavc_abuf == NULL)
910 { 910 {
911 fprintf(stderr, "Couldn't allocate %d bytes\n", lavc_actx->frame_size * 2 * lavc_actx->channels); 911 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_CannotAllocateBytes, lavc_actx->frame_size * 2 * lavc_actx->channels); // Converted from fprintf(stderr, ...);
912 exit(1); 912 exit(1);
913 } 913 }
914 914
915 mux_a->wf = malloc(sizeof(WAVEFORMATEX)+lavc_actx->extradata_size+256); 915 mux_a->wf = malloc(sizeof(WAVEFORMATEX)+lavc_actx->extradata_size+256);
916 mux_a->wf->wFormatTag = lavc_param_atag; 916 mux_a->wf->wFormatTag = lavc_param_atag;
975 sh_audio->sample_format, sh_audio->samplesize, 975 sh_audio->sample_format, sh_audio->samplesize,
976 mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels, 976 mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels,
977 AFMT_S16_NE, 2, 977 AFMT_S16_NE, 2,
978 mux_a->h.dwSuggestedBufferSize, 978 mux_a->h.dwSuggestedBufferSize,
979 mux_a->h.dwSuggestedBufferSize*2)) { 979 mux_a->h.dwSuggestedBufferSize*2)) {
980 mp_msg(MSGT_CPLAYER, MSGL_ERR, "Couldn't find matching filter / ao format!\n"); 980 mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_NoMatchingFilter);
981 exit(1); 981 exit(1);
982 } 982 }
983 983
984 mp_msg(MSGT_MENCODER, MSGL_V, "FRAME_SIZE: %d, BUFFER_SIZE: %d, TAG: 0x%x\n", lavc_actx->frame_size, lavc_actx->frame_size * 2 * lavc_actx->channels, mux_a->wf->wFormatTag); 984 mp_msg(MSGT_MENCODER, MSGL_V, MSGTR_FramesizeBufsizeTag, lavc_actx->frame_size, lavc_actx->frame_size * 2 * lavc_actx->channels, mux_a->wf->wFormatTag);
985 985
986 break; 986 break;
987 #endif 987 #endif
988 } 988 }
989 989
990 if (verbose>1) print_wave_header(mux_a->wf); 990 if (verbose>1) print_wave_header(mux_a->wf);
991 991
992 if(audio_delay!=0.0){ 992 if(audio_delay!=0.0){
993 mux_a->h.dwStart=audio_delay*mux_a->h.dwRate/mux_a->h.dwScale; 993 mux_a->h.dwStart=audio_delay*mux_a->h.dwRate/mux_a->h.dwScale;
994 printf("Setting AUDIO DELAY to %5.3f\n",mux_a->h.dwStart*mux_a->h.dwScale/(float)mux_a->h.dwRate); 994 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_SettingAudioDelay,mux_a->h.dwStart*mux_a->h.dwScale/(float)mux_a->h.dwRate);
995 } 995 }
996 996
997 } // if(sh_audio) 997 } // if(sh_audio)
998 998
999 printf(MSGTR_WritingAVIHeader); 999 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_WritingAVIHeader);
1000 if (muxer->cont_write_header) muxer_write_header(muxer); 1000 if (muxer->cont_write_header) muxer_write_header(muxer);
1001 1001
1002 decoded_frameno=0; 1002 decoded_frameno=0;
1003 1003
1004 if(sh_audio) 1004 if(sh_audio)
1024 if(lame_param_br>0) lame_set_brate(lame,lame_param_br); 1024 if(lame_param_br>0) lame_set_brate(lame,lame_param_br);
1025 } 1025 }
1026 if(lame_param_mode>=0) lame_set_mode(lame,lame_param_mode); // j-st 1026 if(lame_param_mode>=0) lame_set_mode(lame,lame_param_mode); // j-st
1027 if(lame_param_ratio>0) lame_set_compression_ratio(lame,lame_param_ratio); 1027 if(lame_param_ratio>0) lame_set_compression_ratio(lame,lame_param_ratio);
1028 if(lame_param_scale>0) { 1028 if(lame_param_scale>0) {
1029 printf("Setting audio input gain to %f\n", lame_param_scale); 1029 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_SettingAudioInputGain, lame_param_scale);
1030 lame_set_scale(lame,lame_param_scale); 1030 lame_set_scale(lame,lame_param_scale);
1031 } 1031 }
1032 if(lame_param_lowpassfreq>=-1) lame_set_lowpassfreq(lame,lame_param_lowpassfreq); 1032 if(lame_param_lowpassfreq>=-1) lame_set_lowpassfreq(lame,lame_param_lowpassfreq);
1033 if(lame_param_highpassfreq>=-1) lame_set_highpassfreq(lame,lame_param_highpassfreq); 1033 if(lame_param_highpassfreq>=-1) lame_set_highpassfreq(lame,lame_param_highpassfreq);
1034 #if HAVE_MP3LAME >= 392 1034 #if HAVE_MP3LAME >= 392
1035 if(lame_param_preset != NULL){ 1035 if(lame_param_preset != NULL){
1036 printf ("\npreset=%s\n\n",lame_param_preset); 1036 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_LamePresetEquals,lame_param_preset);
1037 lame_presets_set(lame,lame_param_fast, (lame_param_vbr==0), lame_param_preset); 1037 lame_presets_set(lame,lame_param_fast, (lame_param_vbr==0), lame_param_preset);
1038 } 1038 }
1039 #endif 1039 #endif
1040 lame_init_params(lame); 1040 lame_init_params(lame);
1041 if(verbose>0){ 1041 if(verbose>0){
1071 } 1071 }
1072 1072
1073 if (out_file_format == MUXER_TYPE_MPEG) 1073 if (out_file_format == MUXER_TYPE_MPEG)
1074 { 1074 {
1075 if (audio_preload > 0.4) { 1075 if (audio_preload > 0.4) {
1076 fprintf(stderr,"Limiting audio preload to 0.4s\n"); 1076 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_LimitingAudioPreload);
1077 audio_preload = 0.4; 1077 audio_preload = 0.4;
1078 } 1078 }
1079 if (audio_density < 4) { 1079 if (audio_density < 4) {
1080 fprintf(stderr,"Increasing audio density to 4\n"); 1080 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_IncreasingAudioDensity);
1081 audio_density = 4; 1081 audio_density = 4;
1082 } 1082 }
1083 } 1083 }
1084 1084
1085 if(file_format == DEMUXER_TYPE_TV) 1085 if(file_format == DEMUXER_TYPE_TV)
1086 { 1086 {
1087 fprintf(stderr,"Forcing audio preload to 0, max pts correction to 0\n"); 1087 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_ZeroingAudioPreloadAndMaxPtsCorrection);
1088 audio_preload = 0.0; 1088 audio_preload = 0.0;
1089 default_max_pts_correction = 0; 1089 default_max_pts_correction = 0;
1090 } 1090 }
1091 1091
1092 play_n_frames=play_n_frames_mf; 1092 play_n_frames=play_n_frames_mf;
1324 videosamples++; 1324 videosamples++;
1325 videorate+=(GetTimerMS() - ptimer_start); 1325 videorate+=(GetTimerMS() - ptimer_start);
1326 1326
1327 if(skip_flag<0){ 1327 if(skip_flag<0){
1328 // duplicate frame 1328 // duplicate frame
1329 if(file_format != DEMUXER_TYPE_TV && !verbose) printf(MSGTR_DuplicateFrames,-skip_flag); 1329 if(file_format != DEMUXER_TYPE_TV && !verbose) mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_DuplicateFrames,-skip_flag);
1330 while(skip_flag<0){ 1330 while(skip_flag<0){
1331 duplicatedframes++; 1331 duplicatedframes++;
1332 if (!encode_duplicates || !sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE) 1332 if (!encode_duplicates || !sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
1333 muxer_write_chunk(mux_v,0,0); 1333 muxer_write_chunk(mux_v,0,0);
1334 ++skip_flag; 1334 ++skip_flag;
1335 } 1335 }
1336 } else 1336 } else
1337 if(skip_flag>0){ 1337 if(skip_flag>0){
1338 // skip frame 1338 // skip frame
1339 if(file_format != DEMUXER_TYPE_TV && !verbose) printf(MSGTR_SkipFrame); 1339 if(file_format != DEMUXER_TYPE_TV && !verbose) mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_SkipFrame);
1340 skippedframes++; 1340 skippedframes++;
1341 --skip_flag; 1341 --skip_flag;
1342 } 1342 }
1343 1343
1344 if(sh_audio && !demuxer2){ 1344 if(sh_audio && !demuxer2){
1485 (mux_a->size+(mux_a->h.dwLength>>1))/mux_a->h.dwLength; 1485 (mux_a->size+(mux_a->h.dwLength>>1))/mux_a->h.dwLength;
1486 mux_a->h.dwLength=mux_a->size; 1486 mux_a->h.dwLength=mux_a->size;
1487 mux_a->h.dwRate=mux_a->wf->nAvgBytesPerSec; 1487 mux_a->h.dwRate=mux_a->wf->nAvgBytesPerSec;
1488 mux_a->h.dwScale=1; 1488 mux_a->h.dwScale=1;
1489 mux_a->wf->nBlockAlign=1; 1489 mux_a->wf->nBlockAlign=1;
1490 printf("\n\nCBR audio: %ld bytes/sec, %d bytes/block\n", 1490 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_CBRAudioByterate,
1491 mux_a->h.dwRate,((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->nBlockSize); 1491 mux_a->h.dwRate,((MPEGLAYER3WAVEFORMAT*)(mux_a->wf))->nBlockSize);
1492 } 1492 }
1493 #endif 1493 #endif
1494 1494
1495 printf(MSGTR_WritingAVIIndex); 1495 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_WritingAVIIndex);
1496 if (muxer->cont_write_index) muxer_write_index(muxer); 1496 if (muxer->cont_write_index) muxer_write_index(muxer);
1497 muxer_f_size=ftello(muxer_f); 1497 muxer_f_size=ftello(muxer_f);
1498 printf(MSGTR_FixupAVIHeader); 1498 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_FixupAVIHeader);
1499 fseek(muxer_f,0,SEEK_SET); 1499 fseek(muxer_f,0,SEEK_SET);
1500 if (muxer->cont_write_header) muxer_write_header(muxer); // update header 1500 if (muxer->cont_write_header) muxer_write_header(muxer); // update header
1501 if(ferror(muxer_f) || fclose(muxer_f) != 0) { 1501 if(ferror(muxer_f) || fclose(muxer_f) != 0) {
1502 mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, out_filename); 1502 mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, out_filename);
1503 mencoder_exit(1, NULL); 1503 mencoder_exit(1, NULL);
1504 } 1504 }
1505 if(vobsub_writer) 1505 if(vobsub_writer)
1506 vobsub_out_close(vobsub_writer); 1506 vobsub_out_close(vobsub_writer);
1507 1507
1508 if(out_video_codec==VCODEC_FRAMENO && mux_v->timer>100){ 1508 if(out_video_codec==VCODEC_FRAMENO && mux_v->timer>100){
1509 printf(MSGTR_RecommendedVideoBitrate,"650MB",(int)((650*1024*1024-muxer_f_size)/mux_v->timer/125)); 1509 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_RecommendedVideoBitrate,"650MB",(int)((650*1024*1024-muxer_f_size)/mux_v->timer/125));
1510 printf(MSGTR_RecommendedVideoBitrate,"700MB",(int)((700*1024*1024-muxer_f_size)/mux_v->timer/125)); 1510 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_RecommendedVideoBitrate,"700MB",(int)((700*1024*1024-muxer_f_size)/mux_v->timer/125));
1511 printf(MSGTR_RecommendedVideoBitrate,"800MB",(int)((800*1024*1024-muxer_f_size)/mux_v->timer/125)); 1511 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_RecommendedVideoBitrate,"800MB",(int)((800*1024*1024-muxer_f_size)/mux_v->timer/125));
1512 printf(MSGTR_RecommendedVideoBitrate,"2 x 650MB",(int)((2*650*1024*1024-muxer_f_size)/mux_v->timer/125)); 1512 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_RecommendedVideoBitrate,"2 x 650MB",(int)((2*650*1024*1024-muxer_f_size)/mux_v->timer/125));
1513 printf(MSGTR_RecommendedVideoBitrate,"2 x 700MB",(int)((2*700*1024*1024-muxer_f_size)/mux_v->timer/125)); 1513 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_RecommendedVideoBitrate,"2 x 700MB",(int)((2*700*1024*1024-muxer_f_size)/mux_v->timer/125));
1514 printf(MSGTR_RecommendedVideoBitrate,"2 x 800MB",(int)((2*800*1024*1024-muxer_f_size)/mux_v->timer/125)); 1514 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_RecommendedVideoBitrate,"2 x 800MB",(int)((2*800*1024*1024-muxer_f_size)/mux_v->timer/125));
1515 } 1515 }
1516 1516
1517 printf(MSGTR_VideoStreamResult, 1517 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_VideoStreamResult,
1518 (float)(mux_v->size/mux_v->timer*8.0f/1000.0f), (int)(mux_v->size/mux_v->timer), (int)mux_v->size, (float)mux_v->timer, decoded_frameno); 1518 (float)(mux_v->size/mux_v->timer*8.0f/1000.0f), (int)(mux_v->size/mux_v->timer), (int)mux_v->size, (float)mux_v->timer, decoded_frameno);
1519 if(sh_audio) 1519 if(sh_audio)
1520 printf(MSGTR_AudioStreamResult, 1520 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_AudioStreamResult,
1521 (float)(mux_a->size/mux_a->timer*8.0f/1000.0f), (int)(mux_a->size/mux_a->timer), (int)mux_a->size, (float)mux_a->timer); 1521 (float)(mux_a->size/mux_a->timer*8.0f/1000.0f), (int)(mux_a->size/mux_a->timer), (int)mux_a->size, (float)mux_a->timer);
1522 1522
1523 if(sh_video){ uninit_video(sh_video);sh_video=NULL; } 1523 if(sh_video){ uninit_video(sh_video);sh_video=NULL; }
1524 if(demuxer) free_demuxer(demuxer); 1524 if(demuxer) free_demuxer(demuxer);
1525 if(stream) free_stream(stream); // kill cache thread 1525 if(stream) free_stream(stream); // kill cache thread
1607 static int lame_presets_set( lame_t gfp, int fast, int cbr, const char* preset_name ) 1607 static int lame_presets_set( lame_t gfp, int fast, int cbr, const char* preset_name )
1608 { 1608 {
1609 int mono = 0; 1609 int mono = 0;
1610 1610
1611 if (strcmp(preset_name, "help") == 0) { 1611 if (strcmp(preset_name, "help") == 0) {
1612 fprintf(stdout, "LAME version %s (%s)\n\n", get_lame_version(), get_lame_url()); 1612 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_LameVersion, get_lame_version(), get_lame_url());
1613 lame_presets_longinfo_dm( stdout ); 1613 lame_presets_longinfo_dm( stdout );
1614 return -1; 1614 return -1;
1615 } 1615 }
1616 1616
1617 1617
1708 1708
1709 return 0; 1709 return 0;
1710 1710
1711 } 1711 }
1712 else { 1712 else {
1713 fprintf(stderr, "LAME version %s (%s)\n\n", get_lame_version(), get_lame_url()); 1713 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_LameVersion, get_lame_version(), get_lame_url());
1714 fprintf(stderr,"Error: The bitrate specified is out of the valid range for this preset\n" 1714 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_InvalidBitrateForLamePreset);
1715 "\n"
1716 "When using this mode you must enter a value between \"8\" and \"320\"\n"
1717 "\n"
1718 "For further information try: \"-lameopts preset=help\"\n"
1719 );
1720 return -1; 1715 return -1;
1721 } 1716 }
1722 } 1717 }
1723 1718
1724 1719
1725 1720
1726 fprintf(stderr, "LAME version %s (%s)\n\n", get_lame_version(), get_lame_url()); 1721 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_LameVersion, get_lame_version(), get_lame_url());
1727 fprintf(stderr,"Error: You did not enter a valid profile and/or options with preset\n" 1722 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_InvalidLamePresetOptions);
1728 "\n" 1723 mencoder_exit(1, MSGTR_ErrorParsingCommandLine);
1729 "Available profiles are:\n"
1730 "\n"
1731 " <fast> standard\n"
1732 " <fast> extreme\n"
1733 " insane\n"
1734 " <cbr> (ABR Mode) - The ABR Mode is implied. To use it,\n"
1735 " simply specify a bitrate. For example:\n"
1736 " \"preset=185\" activates this\n"
1737 " preset and uses 185 as an average kbps.\n"
1738 "\n"
1739 " Some examples:\n"
1740 "\n"
1741 " \"-lameopts fast:preset=standard \"\n"
1742 " or \"-lameopts cbr:preset=192 \"\n"
1743 " or \"-lameopts preset=172 \"\n"
1744 " or \"-lameopts preset=extreme \"\n"
1745 "\n"
1746 "For further information try: \"-lameopts preset=help\"\n"
1747 );
1748 mencoder_exit(1, "error parsing cmdline");
1749 } 1724 }
1750 #endif 1725 #endif
1751 1726
1752 #if HAVE_MP3LAME >= 392 1727 #if HAVE_MP3LAME >= 392
1753 /* lame_presets_longinfo_dm 1728 /* lame_presets_longinfo_dm
1754 taken out of presets_longinfo_dm in lame-3.93.1/frontend/parse.c and modified */ 1729 taken out of presets_longinfo_dm in lame-3.93.1/frontend/parse.c and modified */
1755 static void lame_presets_longinfo_dm ( FILE* msgfp ) 1730 static void lame_presets_longinfo_dm ( FILE* msgfp )
1756 { 1731 {
1757 fprintf ( msgfp, 1732 mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_LamePresetsLongInfo);
1758 "\n"
1759 "The preset switches are designed to provide the highest possible quality.\n"
1760 "\n"
1761 "They have for the most part been subject to and tuned via rigorous double blind\n"
1762 "listening tests to verify and achieve this objective.\n"
1763 "\n"
1764 "These are continually updated to coincide with the latest developments that\n"
1765 "occur and as a result should provide you with nearly the best quality\n"
1766 "currently possible from LAME.\n"
1767 "\n"
1768 "To activate these presets:\n"
1769 "\n"
1770 " For VBR modes (generally highest quality):\n"
1771 "\n"
1772 " \"preset=standard\" This preset should generally be transparent\n"
1773 " to most people on most music and is already\n"
1774 " quite high in quality.\n"
1775 "\n"
1776 " \"preset=extreme\" If you have extremely good hearing and similar\n"
1777 " equipment, this preset will generally provide\n"
1778 " slightly higher quality than the \"standard\"\n"
1779 " mode.\n"
1780 "\n"
1781 " For CBR 320kbps (highest quality possible from the preset switches):\n"
1782 "\n"
1783 " \"preset=insane\" This preset will usually be overkill for most\n"
1784 " people and most situations, but if you must\n"
1785 " have the absolute highest quality with no\n"
1786 " regard to filesize, this is the way to go.\n"
1787 "\n"
1788 " For ABR modes (high quality per given bitrate but not as high as VBR):\n"
1789 "\n"
1790 " \"preset=<kbps>\" Using this preset will usually give you good\n"
1791 " quality at a specified bitrate. Depending on the\n"
1792 " bitrate entered, this preset will determine the\n"
1793 " optimal settings for that particular situation.\n"
1794 " While this approach works, it is not nearly as\n"
1795 " flexible as VBR, and usually will not attain the\n"
1796 " same level of quality as VBR at higher bitrates.\n"
1797 "\n"
1798 "The following options are also available for the corresponding profiles:\n"
1799 "\n"
1800 " <fast> standard\n"
1801 " <fast> extreme\n"
1802 " insane\n"
1803 " <cbr> (ABR Mode) - The ABR Mode is implied. To use it,\n"
1804 " simply specify a bitrate. For example:\n"
1805 " \"preset=185\" activates this\n"
1806 " preset and uses 185 as an average kbps.\n"
1807 "\n"
1808 " \"fast\" - Enables the new fast VBR for a particular profile. The\n"
1809 " disadvantage to the speed switch is that often times the\n"
1810 " bitrate will be slightly higher than with the normal mode\n"
1811 " and quality may be slightly lower also.\n"
1812 " Warning: with the current version fast presets might result in too\n"
1813 " high bitrate compared to regular presets.\n"
1814 "\n"
1815 " \"cbr\" - If you use the ABR mode (read above) with a significant\n"
1816 " bitrate such as 80, 96, 112, 128, 160, 192, 224, 256, 320,\n"
1817 " you can use the \"cbr\" option to force CBR mode encoding\n"
1818 " instead of the standard abr mode. ABR does provide higher\n"
1819 " quality but CBR may be useful in situations such as when\n"
1820 " streaming an mp3 over the internet may be important.\n"
1821 "\n"
1822 " For example:\n"
1823 "\n"
1824 " \"-lameopts fast:preset=standard \"\n"
1825 " or \"-lameopts cbr:preset=192 \"\n"
1826 " or \"-lameopts preset=172 \"\n"
1827 " or \"-lameopts preset=extreme \"\n"
1828 "\n"
1829 "\n"
1830 "A few aliases are available for ABR mode:\n"
1831 "phone => 16kbps/mono phon+/lw/mw-eu/sw => 24kbps/mono\n"
1832 "mw-us => 40kbps/mono voice => 56kbps/mono\n"
1833 "fm/radio/tape => 112kbps hifi => 160kbps\n"
1834 "cd => 192kbps studio => 256kbps");
1835 mencoder_exit(0, NULL); 1733 mencoder_exit(0, NULL);
1836 } 1734 }
1837 #endif 1735 #endif
1838 1736
1839 #ifdef USE_LIBAVCODEC 1737 #ifdef USE_LIBAVCODEC