summaryrefslogtreecommitdiffstats
path: root/mencoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'mencoder.c')
-rw-r--r--mencoder.c346
1 files changed, 186 insertions, 160 deletions
diff --git a/mencoder.c b/mencoder.c
index 7b9f5705eb..7d92b2983c 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -55,6 +55,7 @@
#include <sys/time.h>
#include "mp_msg.h"
+#include "av_log.h"
#include "help_mp.h"
#include "codec-cfg.h"
@@ -100,9 +101,15 @@
#include "libavcodec/avcodec.h"
#include "libmpcodecs/ae.h"
+#include "options.h"
+#include "defaultopts.h"
+
+MPOpts opts;
+struct osd_state *osd;
+
+const int under_mencoder = 1;
int vo_doublebuffering=0;
int vo_directrendering=0;
-int vo_config_count=1;
int forced_subs_only=0;
//--------------------------
@@ -118,9 +125,6 @@ float stream_cache_seek_min_percent=50.0;
#define cache_fill_status 0
#endif
-int audio_id=-1;
-int video_id=-1;
-int dvdsub_id=-1;
int vobsub_id=-1;
char* audio_lang=NULL;
char* dvdsub_lang=NULL;
@@ -170,7 +174,6 @@ static int audio_density=2;
double force_fps=0;
static double force_ofps=0; // set to 24 for inverse telecine
static int skip_limit=-1;
-float playback_speed=1.0;
static int force_srate=0;
static int audio_output_format=0;
@@ -217,27 +220,30 @@ char *info_sourceform=NULL;
char *info_comment=NULL;
// Needed by libmpcodecs vf_vo.c
-int config_video_out(const vo_functions_t *vo, uint32_t width, uint32_t height,
- uint32_t d_width, uint32_t d_height, uint32_t flags,
- char *title, uint32_t format) {
- return 1;
-}
-// Needed by libmpdemux.
-int mp_input_check_interrupt(int time) {
- usec_sleep(time);
- return 0;
-}
+int vo_config(struct vo *vo, uint32_t width, uint32_t height,
+ uint32_t d_width, uint32_t d_height, uint32_t flags,
+ char *title, uint32_t format) { abort(); }
+int vo_control(struct vo *vo, uint32_t request, void *data) { abort(); }
+void vo_seek_reset(struct vo *vo) { abort(); }
+int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts) { abort(); }
+int vo_draw_frame(struct vo *vo, uint8_t *src[]) { abort(); }
+int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y) { abort(); }
+void vo_draw_osd(struct vo *vo, struct osd_state *osd) { abort(); }
+void vo_flip_page(struct vo *vo, uint32_t pts_us, int duration) { abort(); }
+void vo_check_events(struct vo *vo) { abort(); }
+
// Needed by getch2
-void mplayer_put_key(int code)
+struct mp_fifo;
+void mplayer_put_key(struct mp_fifo *fifo, int code)
{
}
-#include "libass/ass_mp.h"
+#include "ass_mp.h"
char *current_module;
#include "mpcommon.h"
// Needed by mpcommon.c
-void set_osd_subtitle(subtitle *subs) {
+void set_osd_subtitle(struct MPContext *mpctx, subtitle *subs) {
vo_sub = subs;
vo_osd_changed(OSDTYPE_SUBTITLE);
}
@@ -310,9 +316,9 @@ static int edl_seek(edl_record_ptr next_edl_record, demuxer_t* demuxer, demux_st
static void mencoder_exit(int level, const char *how)
{
if (how)
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ExitingHow, how);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "\nExiting... (%s)\n", how);
else
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_Exiting);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "\nExiting...\n");
exit(level);
}
@@ -322,14 +328,14 @@ static void parse_cfgfiles( m_config_t* conf )
char *conffile;
if (!disable_system_conf &&
m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mencoder.conf") < 0)
- mencoder_exit(1,MSGTR_ConfigFileError);
+ mencoder_exit(1,_("config file error"));
if (!disable_user_conf) {
if ((conffile = get_path("mencoder.conf")) == NULL) {
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem);
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"get_path(\"config\") problem\n");
} else {
if (m_config_parse_config_file(conf, conffile) < 0)
- mencoder_exit(1,MSGTR_ConfigFileError);
+ mencoder_exit(1,_("config file error"));
free(conffile);
}
}
@@ -343,7 +349,6 @@ static int dec_audio(sh_audio_t *sh_audio,unsigned char* buffer,int total){
int at_eof=0;
while(size<total && !at_eof){
int len=total-size;
- if(len>MAX_OUTBURST) len=MAX_OUTBURST;
if (decode_audio(sh_audio, len) < 0) at_eof=1;
if(len>sh_audio->a_out_buffer_len) len=sh_audio->a_out_buffer_len;
fast_memcpy(buffer+size,sh_audio->a_out_buffer,len);
@@ -374,28 +379,28 @@ void add_subtitles(char *filename, float fps, int silent)
{
sub_data *subd;
#ifdef CONFIG_ASS
- ass_track_t *asst = 0;
+ ASS_Track *asst = 0;
#endif
if (!filename) return;
subd = sub_read_file(filename, fps);
#ifdef CONFIG_ASS
- if (ass_enabled)
+ if (opts.ass_enabled)
#ifdef CONFIG_ICONV
asst = ass_read_file(ass_library, filename, sub_cp);
#else
asst = ass_read_file(ass_library, filename, 0);
#endif
- if (ass_enabled && subd && !asst)
+ if (opts.ass_enabled && subd && !asst)
asst = ass_read_subdata(ass_library, subd, fps);
if (!asst && !subd && !silent)
#else
if (!subd && !silent)
#endif
- mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadSub,
- filename_recode(filename));
+ mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Cannot load subtitles: %s\n",
+ filename_recode(filename));
#ifdef CONFIG_ASS
if (!asst && !subd) return;
@@ -457,12 +462,12 @@ ao_data_t ao_data = {0,0,0,0,OUTBURST,-1,0};
audio_encoding_params_t aparams;
audio_encoder_t *aencoder = NULL;
-user_correct_pts = 0;
-
mp_msg_init();
+ set_av_log_callback();
// Create the config context and register the options
- mconfig = m_config_new();
+ set_default_mencoder_options(&opts);
+ mconfig = m_config_new(&opts, cfg_include);
m_config_register_options(mconfig,mencoder_opts);
// Preparse the command line
@@ -483,19 +488,19 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
if(!parse_codec_cfg(NULL)){
mencoder_exit(1,NULL);
}
- mp_msg(MSGT_MENCODER,MSGL_V,MSGTR_BuiltinCodecsConf);
+ mp_tmsg(MSGT_MENCODER,MSGL_V,"Using built-in default codecs.conf.\n");
}
}
}
parse_cfgfiles(mconfig);
filelist = m_config_parse_me_command_line(mconfig, argc, argv);
- if(!filelist) mencoder_exit(1, MSGTR_ErrorParsingCommandLine);
+ if(!filelist) mencoder_exit(1, _("error parsing command line"));
{
char *extension;
- if (!out_filename) mencoder_exit(1,MSGTR_MissingOutputFilename);
+ if (!out_filename) mencoder_exit(1,_("No output file specified, please see the -o option."));
extension=strrchr(out_filename,'.');
if (extension != NULL && strlen(extension) > 3 && strlen(extension) < 6)
{
@@ -505,14 +510,14 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
{
case MUXER_TYPE_AVI:
if (strcasecmp(extension,"avi"))
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_MencoderWrongFormatAVI);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "\nWARNING: OUTPUT FILE FORMAT IS _AVI_. See -of help.\n");
break;
case MUXER_TYPE_MPEG:
if (strcasecmp(extension,"mpg") &&
strcasecmp(extension,"mpeg") &&
strcasecmp(extension,"vob"))
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_MencoderWrongFormatMPG);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "\nWARNING: OUTPUT FILE FORMAT IS _MPEG_. See -of help.\n");
break;
}
}
@@ -520,13 +525,16 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
/* Display what configure line was used */
mp_msg(MSGT_MENCODER, MSGL_V, "Configuration: " CONFIGURATION "\n");
+#define FormatNotRecognized _("============ Sorry, this file format is not recognized/supported =============\n"\
+"=== If this file is an AVI, ASF or MPEG stream, please contact the author! ===\n")
+
if (frameno_filename) {
stream2=open_stream(frameno_filename,0,&i);
if(stream2){
- demuxer2=demux_open(stream2,DEMUXER_TYPE_AVI,-1,-1,-2,NULL);
- if(demuxer2) mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_UsingPass3ControlFile, frameno_filename);
- else mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
+ demuxer2=demux_open(&opts, stream2,DEMUXER_TYPE_AVI,-1,-1,-2,NULL);
+ if(demuxer2) mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Using pass3 control file: %s\n", frameno_filename);
+ else mp_tmsg(MSGT_DEMUXER,MSGL_ERR, FormatNotRecognized);
}
}
@@ -545,7 +553,7 @@ if (frameno_filename) {
#ifdef CONFIG_BITMAP_FONT
if(font_name){
vo_font=read_font_desc(font_name,font_factor,verbose>1);
- if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
+ if(!vo_font) mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Cannot load bitmap font: %s\n",font_name);
} else {
// try default:
vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1);
@@ -557,7 +565,7 @@ if (frameno_filename) {
}
#endif
- vo_init_osd();
+ osd = osd_create();
/* HACK, for some weird reason, push() has to be called twice,
otherwise options are not saved correctly */
@@ -572,29 +580,29 @@ play_next_file:
#endif
if(!filename){
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_MissingFilename);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "\nFilename missing.\n\n");
mencoder_exit(1,NULL);
}
stream=open_stream(filename,0,&file_format);
if(!stream){
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_CannotOpenFile_Device);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Cannot open file/device.\n");
mencoder_exit(1,NULL);
}
- mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_OpenedStream, file_format, (int)(stream->start_pos), (int)(stream->end_pos));
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "success: format: %d data: 0x%X - 0x%x\n", file_format, (int)(stream->start_pos), (int)(stream->end_pos));
#ifdef CONFIG_DVDREAD
if(stream->type==STREAMTYPE_DVD){
- if(audio_lang && audio_id==-1) audio_id=dvd_aid_from_lang(stream,audio_lang);
- if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(stream,dvdsub_lang);
+ if(audio_lang && opts.audio_id==-1) opts.audio_id=dvd_aid_from_lang(stream,audio_lang);
+ if(dvdsub_lang && opts.sub_id==-1) opts.sub_id=dvd_sid_from_lang(stream,dvdsub_lang);
}
#endif
#ifdef CONFIG_DVDNAV
if(stream->type==STREAMTYPE_DVDNAV){
- if(audio_lang && audio_id==-1) audio_id=mp_dvdnav_aid_from_lang(stream,audio_lang);
- if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=mp_dvdnav_sid_from_lang(stream,dvdsub_lang);
+ if(audio_lang && opts.audio_id==-1) opts.audio_id=mp_dvdnav_aid_from_lang(stream,audio_lang);
+ if(dvdsub_lang && opts.sub_id==-1) opts.sub_id=mp_dvdnav_sid_from_lang(stream,dvdsub_lang);
}
#endif
@@ -602,35 +610,35 @@ if(stream->type==STREAMTYPE_DVDNAV){
if(stream_cache_size>0) stream_enable_cache(stream,stream_cache_size*1024,0,0);
- if(demuxer2) audio_id=-2; /* do NOT read audio packets... */
+ if(demuxer2) opts.audio_id=-2; /* do NOT read audio packets... */
- //demuxer=demux_open(stream,file_format,video_id,audio_id,dvdsub_id);
- demuxer=demux_open(stream,file_format,audio_id,video_id,dvdsub_id,filename);
+ //demuxer=demux_open(stream,file_format,opts.video_id,opts.audio_id,opts.sub_id);
+ demuxer=demux_open(&opts, stream,file_format,opts.audio_id,opts.video_id,opts.sub_id,filename);
if(!demuxer){
- mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_FormatNotRecognized);
- mp_msg(MSGT_DEMUXER, MSGL_FATAL, MSGTR_CannotOpenDemuxer);
+ mp_tmsg(MSGT_DEMUXER, MSGL_FATAL, FormatNotRecognized);
+ mp_tmsg(MSGT_DEMUXER, MSGL_FATAL, "Cannot open demuxer.\n");
mencoder_exit(1,NULL);
}
if (ts_prog) {
demux_program_t prog = { .progid = ts_prog };
if (demux_control(demuxer, DEMUXER_CTRL_IDENTIFY_PROGRAM, &prog) != DEMUXER_CTRL_NOTIMPL) {
- audio_id = prog.aid; // switching is handled by select_audio below
- video_id = prog.vid;
- demuxer_switch_video(demuxer, video_id);
+ opts.audio_id = prog.aid; // switching is handled by select_audio below
+ opts.video_id = prog.vid;
+ demuxer_switch_video(demuxer, opts.video_id);
}
}
- select_audio(demuxer, audio_id, audio_lang);
+ select_audio(demuxer, opts.audio_id, audio_lang);
- if (dvdsub_id == -1 && dvdsub_lang)
- dvdsub_id = demuxer_sub_track_by_lang(demuxer, dvdsub_lang);
+ if (opts.sub_id < -1 && dvdsub_lang)
+ opts.sub_id = demuxer_sub_track_by_lang(demuxer, dvdsub_lang);
- if (dvdsub_id == -1)
- dvdsub_id = demuxer_default_sub_track(demuxer);
+ if (opts.sub_id < -1)
+ opts.sub_id = demuxer_default_sub_track(demuxer);
for (i = 0; i < MAX_S_STREAMS; i++) {
sh_sub_t *sh = demuxer->s_streams[i];
- if (sh && sh->sid == dvdsub_id) {
+ if (sh && sh->sid == opts.sub_id) {
demuxer->sub->id = i;
demuxer->sub->sh = sh;
break;
@@ -638,8 +646,8 @@ if(stream->type==STREAMTYPE_DVDNAV){
}
if(dvd_chapter>1) {
- float pts;
- if (demuxer_seek_chapter(demuxer, dvd_chapter-1, 1, &pts, NULL, NULL) >= 0 && pts > -1.0)
+ double pts;
+ if (demuxer_seek_chapter(demuxer, dvd_chapter-1, &pts, NULL) >= 0 && pts > -1.0)
seek_to_sec = pts;
}
@@ -651,16 +659,16 @@ sh_video=d_video->sh;
if(!sh_video)
{
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_VideoStreamRequired);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Video stream is mandatory!\n");
mencoder_exit(1,NULL);
}
if(!video_read_properties(sh_video)){
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_CannotReadVideoProperties);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Video: Cannot read properties.\n");
mencoder_exit(1,NULL);
}
- mp_msg(MSGT_MENCODER,MSGL_INFO, MSGTR_FilefmtFourccSizeFpsFtime,
+ mp_tmsg(MSGT_MENCODER,MSGL_INFO, "[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.3f ftime:=%6.4f\n",
demuxer->file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h,
sh_video->fps,sh_video->frametime
);
@@ -668,21 +676,21 @@ sh_video=d_video->sh;
if(force_fps){
sh_video->fps=force_fps;
sh_video->frametime=1.0f/sh_video->fps;
- mp_msg(MSGT_MENCODER,MSGL_INFO,MSGTR_ForcingInputFPS, sh_video->fps);
+ mp_tmsg(MSGT_MENCODER,MSGL_INFO,"Input fps will be interpreted as %5.3f instead.\n", sh_video->fps);
}
if(sh_audio && out_audio_codec<0){
- if(audio_id==-2)
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_DemuxerDoesntSupportNosound);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoAudioEncoderSelected);
+ if(opts.audio_id==-2)
+ mp_tmsg(MSGT_MENCODER,MSGL_ERR,"This demuxer doesn't support -nosound yet.\n");
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nNo audio encoder (-oac) selected. Select one (see -oac help) or use -nosound.\n");
mencoder_exit(1,NULL);
}
if(sh_video && out_video_codec<0){
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoVideoEncoderSelected);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nNo video encoder (-ovc) selected. Select one (see -ovc help).\n");
mencoder_exit(1,NULL);
}
-if(sh_audio && (out_audio_codec || seek_to_sec || !sh_audio->wf || playback_speed != 1.0)){
+if(sh_audio && (out_audio_codec || seek_to_sec || !sh_audio->wf || opts.playback_speed != 1.0)){
// Go through the codec.conf and find the best codec...
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
if(!init_best_audio_codec(sh_audio,audio_codec_list,audio_fm_list)){
@@ -693,12 +701,12 @@ if(sh_audio && (out_audio_codec || seek_to_sec || !sh_audio->wf || playback_spee
if (sh_audio) {
new_srate = sh_audio->samplerate;
- if (playback_speed != 1.0) {
- new_srate *= playback_speed;
+ if (opts.playback_speed != 1.0) {
+ new_srate *= opts.playback_speed;
// limits are taken from libaf/af_resample.c
if (new_srate < 8000) new_srate = 8000;
if (new_srate > 192000) new_srate = 192000;
- playback_speed = (float)new_srate / (float)sh_audio->samplerate;
+ opts.playback_speed = (float)new_srate / (float)sh_audio->samplerate;
}
}
@@ -708,7 +716,7 @@ if (!curfile) { // curfile is non zero when a second file is opened
if (vobsub_out) {
unsigned int palette[16], width, height;
unsigned char tmp[3] = { 0, 0, 0 };
- if (spudec_ifo && vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, dvdsub_id, tmp) >= 0)
+ if (spudec_ifo && vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, opts.sub_id, tmp) >= 0)
vobsub_writer = vobsub_out_open(vobsub_out, palette, sh_video->disp_w, sh_video->disp_h,
vobsub_out_id?vobsub_out_id:(char *)tmp, vobsub_out_index);
#ifdef CONFIG_DVDREAD
@@ -718,7 +726,7 @@ if (vobsub_out) {
int i;
dvd_priv_t *dvd = (dvd_priv_t*)stream->priv;
for (i = 0; i < dvd->nr_of_subtitles; ++i)
- if (dvd->subtitles[i].id == dvdsub_id) {
+ if (dvd->subtitles[i].id == opts.sub_id) {
tmp[0] = (dvd->subtitles[i].language >> 8) & 0xff;
tmp[1] = dvd->subtitles[i].language & 0xff;
tmp[2] = 0;
@@ -749,13 +757,13 @@ if (vo_spudec)
ostream = open_output_stream(out_filename, 0);
if(!ostream) {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CannotOpenOutputFile, out_filename);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Cannot open output file '%s'.\n", out_filename);
mencoder_exit(1,NULL);
}
muxer=muxer_new_muxer(out_file_format,ostream);
if(!muxer) {
- mp_msg(MSGT_MENCODER, MSGL_FATAL, MSGTR_CannotInitializeMuxer);
+ mp_tmsg(MSGT_MENCODER, MSGL_FATAL, "Cannot initialize muxer.");
mencoder_exit(1,NULL);
}
#if 0
@@ -777,14 +785,14 @@ mux_v->source=sh_video;
mux_v->h.dwSampleSize=0; // VBR
#ifdef CONFIG_LIBAVCODEC
{
- double fps = force_ofps?force_ofps:sh_video->fps*playback_speed;
+ double fps = force_ofps?force_ofps:sh_video->fps*opts.playback_speed;
AVRational q= av_d2q(fps, fps*1001+2);
mux_v->h.dwScale= q.den;
mux_v->h.dwRate = q.num;
}
#else
mux_v->h.dwScale=10000;
-mux_v->h.dwRate=mux_v->h.dwScale*(force_ofps?force_ofps:sh_video->fps*playback_speed);
+mux_v->h.dwRate=mux_v->h.dwScale*(force_ofps?force_ofps:sh_video->fps*opts.playback_speed);
#endif
mux_v->codec=out_video_codec;
@@ -813,7 +821,7 @@ case VCODEC_COPY:
mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8);
}
}
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_VCodecFramecopy,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "videocodec: framecopy (%dx%d %dbpp fourcc=%x)\n",
mux_v->bih->biWidth, mux_v->bih->biHeight,
mux_v->bih->biBitCount, mux_v->bih->biCompression);
@@ -822,10 +830,10 @@ case VCODEC_COPY:
if ((mux_v->bih->biSize != sh_video->bih->biSize) ||
memcmp(mux_v->bih, sh_video->bih, sh_video->bih->biSize))
{
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_VCodecFramecopy,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "videocodec: framecopy (%dx%d %dbpp fourcc=%x)\n",
sh_video->bih->biWidth, sh_video->bih->biHeight,
sh_video->bih->biBitCount, sh_video->bih->biCompression);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_FrameCopyFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nAll video files must have identical fps, resolution, and codec for -ovc copy.\n");
mencoder_exit(1,NULL);
}
}
@@ -833,9 +841,9 @@ case VCODEC_COPY:
if ((mux_v->bih->biWidth != sh_video->disp_w) ||
(mux_v->bih->biHeight != sh_video->disp_h) ||
(mux_v->bih->biCompression != sh_video->format)) {
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_VCodecFramecopy,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "videocodec: framecopy (%dx%d %dbpp fourcc=%x)\n",
sh_video->disp_w, sh_video->disp_w, 24, sh_video->format);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_FrameCopyFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nAll video files must have identical fps, resolution, and codec for -ovc copy.\n");
mencoder_exit(1,NULL);
}
}
@@ -858,45 +866,45 @@ default: {
if (!ve) {
switch(mux_v->codec){
case VCODEC_LIBAVCODEC:
- sh_video->vfilter=vf_open_encoder(NULL,"lavc",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"lavc",(char *)mux_v); break;
case VCODEC_RAW:
- sh_video->vfilter=vf_open_encoder(NULL,"raw",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"raw",(char *)mux_v); break;
case VCODEC_VFW:
- sh_video->vfilter=vf_open_encoder(NULL,"vfw",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"vfw",(char *)mux_v); break;
case VCODEC_LIBDV:
- sh_video->vfilter=vf_open_encoder(NULL,"libdv",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"libdv",(char *)mux_v); break;
case VCODEC_XVID:
- sh_video->vfilter=vf_open_encoder(NULL,"xvid",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"xvid",(char *)mux_v); break;
case VCODEC_QTVIDEO:
- sh_video->vfilter=vf_open_encoder(NULL,"qtvideo",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"qtvideo",(char *)mux_v); break;
case VCODEC_NUV:
- sh_video->vfilter=vf_open_encoder(NULL,"nuv",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"nuv",(char *)mux_v); break;
case VCODEC_X264:
- sh_video->vfilter=vf_open_encoder(NULL,"x264",(char *)mux_v); break;
+ sh_video->vfilter=vf_open_encoder(&opts, NULL,"x264",(char *)mux_v); break;
}
if(!mux_v->bih || !sh_video->vfilter){
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_EncoderOpenFailed);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"Failed to open the encoder.\n");
mencoder_exit(1,NULL);
}
ve = sh_video->vfilter;
} else sh_video->vfilter = ve;
// append 'expand' filter, it fixes stride problems and renders osd:
#ifdef CONFIG_ASS
- if (auto_expand && !ass_enabled) { /* we do not want both */
+ if (auto_expand && !opts.ass_enabled) { /* we do not want both */
#else
if (auto_expand) {
#endif
char* vf_args[] = { "osd", "1", NULL };
- sh_video->vfilter=vf_open_filter(sh_video->vfilter,"expand",vf_args);
+ sh_video->vfilter=vf_open_filter(&opts, sh_video->vfilter,"expand",vf_args);
}
#ifdef CONFIG_ASS
- if(ass_enabled) {
+ if(opts.ass_enabled) {
int i;
int insert = 1;
- if (vf_settings)
- for (i = 0; vf_settings[i].name; ++i)
- if (strcmp(vf_settings[i].name, "ass") == 0) {
+ if (opts.vf_settings)
+ for (i = 0; opts.vf_settings[i].name; ++i)
+ if (strcmp(opts.vf_settings[i].name, "ass") == 0) {
insert = 0;
break;
}
@@ -904,7 +912,7 @@ default: {
extern vf_info_t vf_info_ass;
vf_info_t* libass_vfs[] = {&vf_info_ass, NULL};
char* vf_arg[] = {"auto", "1", NULL};
- vf_instance_t* vf_ass = vf_open_plugin(libass_vfs,sh_video->vfilter,"ass",vf_arg);
+ vf_instance_t* vf_ass = vf_open_plugin(&opts,libass_vfs,sh_video->vfilter,"ass",vf_arg);
if (vf_ass)
sh_video->vfilter=(void*)vf_ass;
else
@@ -914,7 +922,7 @@ default: {
if (ass_library) {
for (i = 0; i < demuxer->num_attachments; ++i) {
demux_attachment_t* att = demuxer->attachments + i;
- if (extract_embedded_fonts &&
+ if (use_embedded_fonts &&
att->name && att->type && att->data && att->data_size &&
(strcmp(att->type, "application/x-truetype-font") == 0 ||
strcmp(att->type, "application/x-font") == 0))
@@ -924,10 +932,10 @@ default: {
}
#endif
- sh_video->vfilter=append_filters(sh_video->vfilter);
+ sh_video->vfilter=append_filters(sh_video->vfilter, opts.vf_settings);
#ifdef CONFIG_ASS
- if (ass_enabled)
+ if (opts.ass_enabled)
((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_INIT_EOSD, ass_library);
#endif
@@ -965,7 +973,7 @@ if ((force_fourcc != NULL) && (strlen(force_fourcc) >= 4))
{
mux_v->bih->biCompression = mmioFOURCC(force_fourcc[0], force_fourcc[1],
force_fourcc[2], force_fourcc[3]);
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ForcingOutputFourcc,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Forcing output FourCC to %x [%.4s].\n",
mux_v->bih->biCompression, (char *)&mux_v->bih->biCompression);
}
@@ -982,7 +990,7 @@ if (force_audiofmttag != -1) {
if (sh_audio->wf) {
sh_audio->wf->wFormatTag = sh_audio->format;
}
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ForcingOutputAudiofmtTag,
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "Forcing output audio format tag to 0x%x.\n",
force_audiofmttag);
}
@@ -991,7 +999,7 @@ mux_a=muxer_new_stream(muxer,MUXER_TYPE_AUDIO);
mux_a->buffer_size=0x100000; //16384;
mux_a->buffer=malloc(mux_a->buffer_size);
if (!mux_a->buffer)
- mencoder_exit(1,MSGTR_MemAllocFailed);
+ mencoder_exit(1,_("Memory allocation failed.\n"));
mux_a->source=sh_audio;
@@ -1005,7 +1013,7 @@ if(!init_audio_filters(sh_audio,
new_srate,
// output:
&ao_data.samplerate, &ao_data.channels, &ao_data.format)) {
- mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_AudioFilterChainPreinitError);
+ mp_tmsg(MSGT_CPLAYER,MSGL_ERR,"Error at audio filter chain pre-init!\n");
mencoder_exit(1, NULL);
}
@@ -1019,15 +1027,19 @@ if(mux_a->codec != ACODEC_COPY) {
if(!init_audio_filters(sh_audio,
new_srate,
&aparams.sample_rate, &aparams.channels, &aencoder->input_format)) {
- mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_NoMatchingFilter);
+ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Couldn't find matching filter/ao format!\n");
mencoder_exit(1,NULL);
}
}
+
+#define NoSpeedWithFrameCopy _("WARNING: -speed is not guaranteed to work correctly with -oac copy!\n"\
+"Your encode might be broken!\n")
+
switch(mux_a->codec){
case ACODEC_COPY:
- if (playback_speed != 1.0) mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_NoSpeedWithFrameCopy);
+ if (opts.playback_speed != 1.0) mp_tmsg(MSGT_CPLAYER, MSGL_WARN, NoSpeedWithFrameCopy);
if (sh_audio->format >= 0x10000) {
- mp_msg(MSGT_MENCODER,MSGL_ERR,MSGTR_CantCopyAudioFormat, sh_audio->format);
+ mp_tmsg(MSGT_MENCODER,MSGL_ERR,"Audio format 0x%x is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it.\n", sh_audio->format);
mencoder_exit(1,NULL);
}
if (sh_audio->wf){
@@ -1053,9 +1065,9 @@ case ACODEC_COPY:
mux_a->h.dwScale=mux_a->h.dwSampleSize;
mux_a->h.dwRate=mux_a->wf->nAvgBytesPerSec;
}
- mux_a->h.dwRate *= playback_speed;
- mux_a->wf->nSamplesPerSec *= playback_speed;
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ACodecFramecopy,
+ mux_a->h.dwRate *= opts.playback_speed;
+ mux_a->wf->nSamplesPerSec *= opts.playback_speed;
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "audiocodec: framecopy (format=%x chans=%d rate=%d bits=%d B/s=%d sample-%d)\n",
mux_a->wf->wFormatTag, mux_a->wf->nChannels, mux_a->wf->nSamplesPerSec,
mux_a->wf->wBitsPerSample, mux_a->wf->nAvgBytesPerSec, mux_a->h.dwSampleSize);
break;
@@ -1080,34 +1092,34 @@ timer_start=GetTimerMS();
} // if (!curfile) // if this was the first file.
else {
if (!mux_a != !sh_audio) {
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_NoAudioFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nCannot mix video-only files with audio and video files. Try -nosound.\n");
mencoder_exit(1,NULL);
}
if (sh_audio && mux_a->codec == ACODEC_COPY) {
- if (playback_speed != 1.0) mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_NoSpeedWithFrameCopy);
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ACodecFramecopy,
+ if (opts.playback_speed != 1.0) mp_tmsg(MSGT_CPLAYER, MSGL_WARN, NoSpeedWithFrameCopy);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "audiocodec: framecopy (format=%x chans=%d rate=%d bits=%d B/s=%d sample-%d)\n",
mux_a->wf->wFormatTag, mux_a->wf->nChannels, mux_a->wf->nSamplesPerSec,
mux_a->wf->wBitsPerSample, mux_a->wf->nAvgBytesPerSec, mux_a->h.dwSampleSize);
if (sh_audio->wf) {
if ((mux_a->wf->wFormatTag != sh_audio->wf->wFormatTag) ||
(mux_a->wf->nChannels != sh_audio->wf->nChannels) ||
- (mux_a->wf->nSamplesPerSec != sh_audio->wf->nSamplesPerSec * playback_speed))
+ (mux_a->wf->nSamplesPerSec != sh_audio->wf->nSamplesPerSec * opts.playback_speed))
{
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ACodecFramecopy,
- sh_audio->wf->wFormatTag, sh_audio->wf->nChannels, (int)(sh_audio->wf->nSamplesPerSec * playback_speed),
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "audiocodec: framecopy (format=%x chans=%d rate=%d bits=%d B/s=%d sample-%d)\n",
+ sh_audio->wf->wFormatTag, sh_audio->wf->nChannels, (int)(sh_audio->wf->nSamplesPerSec * opts.playback_speed),
sh_audio->wf->wBitsPerSample, sh_audio->wf->nAvgBytesPerSec, 0);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_AudioCopyFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nAll files must have identical audio codec and format for -oac copy.\n");
mencoder_exit(1,NULL);
}
} else {
if ((mux_a->wf->wFormatTag != sh_audio->format) ||
(mux_a->wf->nChannels != sh_audio->channels) ||
- (mux_a->wf->nSamplesPerSec != sh_audio->samplerate * playback_speed))
+ (mux_a->wf->nSamplesPerSec != sh_audio->samplerate * opts.playback_speed))
{
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_ACodecFramecopy,
- sh_audio->wf->wFormatTag, sh_audio->wf->nChannels, (int)(sh_audio->wf->nSamplesPerSec * playback_speed),
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "audiocodec: framecopy (format=%x chans=%d rate=%d bits=%d B/s=%d sample-%d)\n",
+ sh_audio->wf->wFormatTag, sh_audio->wf->nChannels, (int)(sh_audio->wf->nSamplesPerSec * opts.playback_speed),
sh_audio->wf->wBitsPerSample, sh_audio->wf->nAvgBytesPerSec, 0);
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_AudioCopyFileMismatch);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"\nAll files must have identical audio codec and format for -oac copy.\n");
mencoder_exit(1,NULL);
}
}
@@ -1118,7 +1130,7 @@ else {
if (!init_audio_filters(sh_audio, new_srate,
&out_srate, &out_channels,
&out_format)) {
- mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_NoMatchingFilter);
+ mp_tmsg(MSGT_CPLAYER, MSGL_FATAL, "Couldn't find matching filter/ao format!\n");
mencoder_exit(1, NULL);
}
mux_a->wf->nSamplesPerSec = out_srate;
@@ -1138,18 +1150,18 @@ if (seek_to_sec) {
if (out_file_format == MUXER_TYPE_MPEG)
{
if (audio_preload > 0.4) {
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_LimitingAudioPreload);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "Limiting audio preload to 0.4s.\n");
audio_preload = 0.4;
}
if (audio_density < 4) {
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_IncreasingAudioDensity);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "Increasing audio density to 4.\n");
audio_density = 4;
}
}
if(file_format == DEMUXER_TYPE_TV)
{
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_ZeroingAudioPreloadAndMaxPtsCorrection);
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "Forcing audio preload to 0, max pts correction to 0.\n");
audio_preload = 0.0;
default_max_pts_correction = 0;
}
@@ -1332,7 +1344,7 @@ if(sh_audio){
frame_data.in_size=video_read_frame(sh_video,&frame_data.frame_time,&frame_data.start,force_fps);
sh_video->timer+=frame_data.frame_time;
}
- frame_data.frame_time /= playback_speed;
+ frame_data.frame_time /= opts.playback_speed;
if(frame_data.in_size<0){ at_eof=1; break; }
++decoded_frameno;
@@ -1405,9 +1417,16 @@ case VCODEC_FRAMENO:
break;
default:
// decode_video will callback down to ve_*.c encoders, through the video filters
+ sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SET_OSD_OBJ, osd);
{void *decoded_frame = decode_video(sh_video,frame_data.start,frame_data.in_size,
- skip_flag>0 && (!sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) != CONTROL_TRUE), MP_NOPTS_VALUE);
- blit_frame = decoded_frame && filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE);}
+ skip_flag>0 && (!sh_video->vfilter || sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) != CONTROL_TRUE), MP_NOPTS_VALUE);
+ blit_frame = decoded_frame && filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE);
+ if (blit_frame) {
+ struct vf_instance *vf = sh_video->vfilter;
+ vf->control(vf, VFCTRL_DRAW_EOSD, NULL);
+ vf->control(vf, VFCTRL_DRAW_OSD, osd);
+ }
+ }
if (sh_video->vf_initialized < 0) mencoder_exit(1, NULL);
@@ -1426,7 +1445,7 @@ default:
// Eventually this entire block should probably be removed.
if(skip_limit==0){
// skipping not allowed -> write empty frame:
- if (!encode_duplicates || !sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
+ if (!encode_duplicates || !sh_video->vfilter || sh_video->vfilter->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
muxer_write_chunk(mux_v,0,0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
} else {
// skipping allowed -> skip it and distriubute timer error:
@@ -1442,17 +1461,17 @@ videorate+=(GetTimerMS() - ptimer_start);
if(skip_flag<0){
// duplicate frame
- if(!quiet) mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_DuplicateFrames,-skip_flag);
+ if(!quiet) mp_tmsg(MSGT_MENCODER, MSGL_WARN, "\n%d duplicate frame(s)!\n",-skip_flag);
while(skip_flag<0){
duplicatedframes++;
- if (!encode_duplicates || !sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
+ if (!encode_duplicates || !sh_video->vfilter || sh_video->vfilter->control(sh_video->vfilter, VFCTRL_DUPLICATE_FRAME, 0) != CONTROL_TRUE)
muxer_write_chunk(mux_v,0,0, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
++skip_flag;
}
} else
if(skip_flag>0){
// skip frame
- if(!quiet) mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_SkipFrame);
+ if(!quiet) mp_tmsg(MSGT_MENCODER, MSGL_WARN, "\nSkipping frame!\n");
skippedframes++;
--skip_flag;
}
@@ -1481,7 +1500,7 @@ if(sh_audio && !demuxer2){
// av = compensated (with out buffering delay) A-V diff
AV_delay=(a_pts-v_pts);
AV_delay-=audio_delay;
- AV_delay /= playback_speed;
+ AV_delay /= opts.playback_speed;
AV_delay-=mux_a->timer-(mux_v->timer-(v_timer_corr+v_pts_corr));
// adjust for encoder delays
AV_delay -= (float) mux_a->encoder_delay * mux_a->h.dwScale/mux_a->h.dwRate;
@@ -1491,9 +1510,9 @@ if(sh_audio && !demuxer2){
if(x<-max_pts_correction) x=-max_pts_correction; else
if(x> max_pts_correction) x= max_pts_correction;
if(default_max_pts_correction>=0)
- max_pts_correction=default_max_pts_correction*playback_speed;
+ max_pts_correction=default_max_pts_correction*opts.playback_speed;
else
- max_pts_correction=sh_video->frametime*0.10 *playback_speed; // +-10% of time
+ max_pts_correction=sh_video->frametime*0.10 *opts.playback_speed; // +-10% of time
// sh_video->timer-=x;
c_total+=x;
v_pts_corr+=x;
@@ -1573,13 +1592,13 @@ if(sh_audio && !demuxer2){
}
else
#endif
- update_subtitles(sh_video, sh_video->pts, d_dvdsub, 0);
+ update_subtitles(NULL, &opts, sh_video, sh_video->pts, 0, d_dvdsub, 0);
frame_data = (s_frame_data){ .start = NULL, .in_size = 0, .frame_time = 0., .already_read = 0 };
#if 0
if(ferror(muxer_f)) {
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, out_filename);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"%s: Error writing file.\n", out_filename);
mencoder_exit(1, NULL);
}
#endif
@@ -1609,11 +1628,11 @@ if (!interrupted && filelist[++curfile].name != 0) {
/* Emit the remaining frames in the video system */
/*TODO emit frmaes delayed by decoder lag*/
if(sh_video && sh_video->vfilter){
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_FlushingVideoFrames);
- if (!((vf_instance_t *)sh_video->vfilter)->fmt.have_configured)
- mp_msg(MSGT_MENCODER, MSGL_WARN, MSGTR_FiltersHaveNotBeenConfiguredEmptyFile);
+ mp_tmsg(MSGT_MENCODER, MSGL_INFO, "\nFlushing video frames.\n");
+ if (!sh_video->vfilter->fmt.have_configured)
+ mp_tmsg(MSGT_MENCODER, MSGL_WARN, "Filters have not been configured! Empty file?\n");
else
- ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter,
+ sh_video->vfilter->control(sh_video->vfilter,
VFCTRL_FLUSH_FRAMES, 0);
}
@@ -1627,7 +1646,7 @@ stream_seek(muxer->stream,0);
if (muxer->cont_write_header) muxer_write_header(muxer); // update header
#if 0
if(ferror(muxer_f) || fclose(muxer_f) != 0) {
- mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, out_filename);
+ mp_tmsg(MSGT_MENCODER,MSGL_FATAL,"%s: Error writing file.\n", out_filename);
mencoder_exit(1, NULL);
}
#endif
@@ -1635,18 +1654,18 @@ if(vobsub_writer)
vobsub_out_close(vobsub_writer);
if(out_video_codec==VCODEC_FRAMENO && mux_v->timer>100){
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_RecommendedVideoBitrate,"650MB",(int)((650*1024*1024-muxer_f_size)/mux_v->timer/125));
- mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_RecommendedVideoBitrate,"700MB",(int)((700*1024*1024-muxer_f_size)/mux_