From 50a86fcc343f1026ee8cab0d9788c6bee35e720b Mon Sep 17 00:00:00 2001 From: mosu Date: Thu, 25 Nov 2004 22:24:00 +0000 Subject: Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14047 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_mkv.c | 15 +++++++++++++++ libmpdemux/demux_ogg.c | 35 +++++++++++++++++++++++++++++++++++ libmpdemux/demux_ts.c | 16 ++++++++++++++++ libmpdemux/demuxer.c | 10 ++++++++++ libmpdemux/open.c | 12 ++++++++++++ mencoder.c | 1 + mp_msg.h | 4 +++- mplayer.c | 5 +++++ vobsub.c | 6 ++++++ 9 files changed, 103 insertions(+), 1 deletion(-) diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index a78edf4c86..889c25c09e 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -228,6 +228,7 @@ typedef struct __attribute__((__packed__)) extern char *dvdsub_lang; extern char *audio_lang; extern int dvdsub_id; +extern int demux_aid_vid_mismatch; static mkv_track_t * @@ -1484,14 +1485,26 @@ display_tracks (mkv_demuxer_t *mkv_d) { case MATROSKA_TRACK_VIDEO: type = "video"; + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", vid); sprintf (str, "-vid %u", vid++); break; case MATROSKA_TRACK_AUDIO: type = "audio"; + if (identify) + { + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", aid); + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AID_%d_LANG=%s\n", aid, mkv_d->tracks[i]->language); + } sprintf (str, "-aid %u, -alang %.5s",aid++,mkv_d->tracks[i]->language); break; case MATROSKA_TRACK_SUBTITLE: type = "subtitles"; + if (identify) + { + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sid); + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SID_%d_LANG=%s\n", sid, mkv_d->tracks[i]->language); + } sprintf (str, "-sid %u, -slang %.5s",sid++,mkv_d->tracks[i]->language); break; } @@ -2097,6 +2110,8 @@ demux_mkv_open (demuxer_t *demuxer) mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] + a segment...\n"); + demux_aid_vid_mismatch = 1; // don't identify in new_sh_* since ids don't match + mkv_d = (mkv_demuxer_t *) malloc (sizeof (mkv_demuxer_t)); memset (mkv_d, 0, sizeof(mkv_demuxer_t)); demuxer->priv = mkv_d; diff --git a/libmpdemux/demux_ogg.c b/libmpdemux/demux_ogg.c index d26381df27..c885358834 100644 --- a/libmpdemux/demux_ogg.c +++ b/libmpdemux/demux_ogg.c @@ -116,6 +116,7 @@ typedef struct ogg_stream { int theora; int flac; int text; + int id; } ogg_stream_t; typedef struct ogg_demuxer { @@ -150,6 +151,7 @@ extern int index_mode; extern char *dvdsub_lang, *audio_lang; extern int dvdsub_id; +extern int demux_aid_vid_mismatch; //-------- subtitle support - should be moved to decoder layer, and queue // - subtitles up in demuxer buffer... @@ -448,6 +450,13 @@ static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os, int id, vor else if (!strncasecmp(*cmt, "LANGUAGE=", 9)) { val = *cmt + 9; + if (identify) + { + if (ogg_d->subs[id].text) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SID_%d_LANG=%s\n", ogg_d->subs[id].id, val); + else if (id != d->video->id) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AID_%d_LANG=%s\n", ogg_d->subs[id].id, val); + } // copy this language name into the array index = demux_ogg_sub_reverse_id(d, id); if (index >= 0) { @@ -797,11 +806,16 @@ int demux_ogg_open(demuxer_t* demuxer) { sh_a = NULL; sh_v = NULL; + demux_aid_vid_mismatch = 1; // don't identify in new_sh_* since ids don't match + // Check for Vorbis if(pack.bytes >= 7 && ! strncmp(&pack.packet[1],"vorbis", 6) ) { sh_a = new_sh_audio(demuxer,ogg_d->num_sub); sh_a->format = 0xFFFE; ogg_d->subs[ogg_d->num_sub].vorbis = 1; + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio); + ogg_d->subs[ogg_d->num_sub].id = n_audio; n_audio++; mp_msg(MSGT_DEMUX,MSGL_V,"Ogg : stream %d is vorbis\n",ogg_d->num_sub); @@ -839,6 +853,9 @@ int demux_ogg_open(demuxer_t* demuxer) { sh_v->bih->biWidth*sh_v->bih->biHeight); ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps; ogg_d->subs[ogg_d->num_sub].theora = 1; + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", n_video); + ogg_d->subs[ogg_d->num_sub].id = n_video; n_video++; mp_msg(MSGT_DEMUX,MSGL_V, "Ogg : stream %d is theora v%i.%i.%i %i:%i, %.3f FPS," @@ -856,6 +873,9 @@ int demux_ogg_open(demuxer_t* demuxer) { } else if (pack.bytes >= 4 && !strncmp (&pack.packet[0], "fLaC", 4)) { sh_a = new_sh_audio(demuxer,ogg_d->num_sub); sh_a->format = mmioFOURCC('f', 'L', 'a', 'C'); + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio); + ogg_d->subs[ogg_d->num_sub].id = n_audio; n_audio++; ogg_d->subs[ogg_d->num_sub].flac = 1; sh_a->wf = NULL; @@ -883,6 +903,9 @@ int demux_ogg_open(demuxer_t* demuxer) { sh_v->bih->biSizeImage=(sh_v->bih->biBitCount>>3)*sh_v->bih->biWidth*sh_v->bih->biHeight; ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps; + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", n_video); + ogg_d->subs[ogg_d->num_sub].id = n_video; n_video++; mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is video (old hdr)\n",ogg_d->num_sub); if(verbose>0) print_video_header(sh_v->bih); @@ -904,6 +927,9 @@ int demux_ogg_open(demuxer_t* demuxer) { memcpy(sh_a->wf+sizeof(WAVEFORMATEX),pack.packet+142,extra_size); ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels; + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio); + ogg_d->subs[ogg_d->num_sub].id = n_audio; n_audio++; mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is audio (old hdr)\n",ogg_d->num_sub); if(verbose>0) print_wave_header(sh_a->wf); @@ -932,6 +958,9 @@ int demux_ogg_open(demuxer_t* demuxer) { sh_v->bih->biSizeImage=(sh_v->bih->biBitCount>>3)*sh_v->bih->biWidth*sh_v->bih->biHeight; ogg_d->subs[ogg_d->num_sub].samplerate= sh_v->fps; + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", n_video); + ogg_d->subs[ogg_d->num_sub].id = n_video; n_video++; mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is video (new hdr)\n",ogg_d->num_sub); if(verbose>0) print_video_header(sh_v->bih); @@ -955,6 +984,9 @@ int demux_ogg_open(demuxer_t* demuxer) { memcpy(sh_a->wf+sizeof(WAVEFORMATEX),st+1,extra_size); ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels; + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio); + ogg_d->subs[ogg_d->num_sub].id = n_audio; n_audio++; mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is audio (new hdr)\n",ogg_d->num_sub); if(verbose>0) print_wave_header(sh_a->wf); @@ -964,6 +996,9 @@ int demux_ogg_open(demuxer_t* demuxer) { mp_msg(MSGT_DEMUX, MSGL_V, "Ogg stream %d is text\n", ogg_d->num_sub); ogg_d->subs[ogg_d->num_sub].samplerate= get_uint64(&st->time_unit)/10; ogg_d->subs[ogg_d->num_sub].text = 1; + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", ogg_d->n_text); + ogg_d->subs[ogg_d->num_sub].id = ogg_d->n_text; if (demuxer->sub->id == ogg_d->n_text) text_id = ogg_d->num_sub; ogg_d->n_text++; diff --git a/libmpdemux/demux_ts.c b/libmpdemux/demux_ts.c index 1f3a19c0cc..6e377d4a11 100644 --- a/libmpdemux/demux_ts.c +++ b/libmpdemux/demux_ts.c @@ -54,6 +54,7 @@ int ts_prog; int ts_keep_broken=0; off_t ts_probe = TS_MAX_PROBE_SIZE; extern char *dvdsub_lang, *audio_lang; //for -alang +extern int demux_aid_vid_mismatch; typedef enum { @@ -510,12 +511,20 @@ static off_t ts_detect_streams(demuxer_t *demuxer, tsdemux_init_t *param) if(is_video) { + if (identify) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", es.pid); chosen_pid = (req_vpid == es.pid); if((! chosen_pid) && (req_vpid > 0)) continue; } else if(is_audio) { + if (identify) + { + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", es.pid); + if (es.lang[0] > 0) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AID_%d_LANG=%s\n", es.pid, es.lang); + } if(req_apid > 0) { chosen_pid = (req_apid == es.pid); @@ -533,6 +542,12 @@ static off_t ts_detect_streams(demuxer_t *demuxer, tsdemux_init_t *param) } else if(is_sub) { + if (identify) + { + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", es.pid); + if (es.lang[0] > 0) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SID_%d_LANG=%s\n", es.pid, es.lang); + } chosen_pid = (req_spid == es.pid); if((! chosen_pid) && (req_spid > 0)) continue; @@ -788,6 +803,7 @@ demuxer_t *demux_open_ts(demuxer_t * demuxer) demuxer->sub->id = params.spid; priv->prog = params.prog; + demux_aid_vid_mismatch = 1; // don't identify in new_sh_* since ids don't match if(params.vtype != UNKNOWN) { diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 43484d1086..167ef18e6e 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -21,6 +21,10 @@ #include "../libao2/afmt.h" #include "../libvo/fastmemcpy.h" +// Should be set to 1 by demux module if ids it passes to new_sh_audio and +// new_sh_video don't match aids and vids it accepts from the command line +int demux_aid_vid_mismatch = 0; + void free_demuxer_stream(demux_stream_t *ds){ ds_free_packs(ds); free(ds); @@ -89,6 +93,8 @@ sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){ sh->samplesize=2; sh->sample_format=AFMT_S16_NE; sh->audio_out_minsize=8192;/* default size, maybe not enough for Win32/ACM*/ + if (identify && !demux_aid_vid_mismatch) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", id); } return demuxer->a_streams[id]; } @@ -112,6 +118,8 @@ sh_video_t* new_sh_video(demuxer_t *demuxer,int id){ mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundVideoStream,id); demuxer->v_streams[id]=malloc(sizeof(sh_video_t)); memset(demuxer->v_streams[id],0,sizeof(sh_video_t)); + if (identify && !demux_aid_vid_mismatch) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", id); } return demuxer->v_streams[id]; } @@ -1404,6 +1412,8 @@ demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int demuxer_t *vd,*ad = NULL,*sd = NULL; int afmt =DEMUXER_TYPE_UNKNOWN,sfmt = DEMUXER_TYPE_UNKNOWN ; + demux_aid_vid_mismatch = 0; + if(audio_stream) { as = open_stream(audio_stream,0,&afmt); if(!as) { diff --git a/libmpdemux/open.c b/libmpdemux/open.c index 300acb87a8..50ae30e707 100644 --- a/libmpdemux/open.c +++ b/libmpdemux/open.c @@ -378,6 +378,12 @@ if(strncmp("dvd://",filename,6) == 0){ tmp, d->audio_streams[d->nr_of_channels].id ); + if (identify) + { + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", d->audio_streams[d->nr_of_channels].id); + if (language && tmp[0]) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AID_%d_LANG=%s\n", d->audio_streams[d->nr_of_channels].id, tmp); + } d->nr_of_channels++; } @@ -414,6 +420,12 @@ if(strncmp("dvd://",filename,6) == 0){ d->nr_of_subtitles, tmp ); + if (identify) + { + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", d->nr_of_subtitles); + if (language && tmp[0]) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SID_%d_LANG=%s\n", d->nr_of_subtitles, tmp); + } d->nr_of_subtitles++; } mp_msg(MSGT_OPEN,MSGL_V,"[open] number of subtitles on disk: %d\n",d->nr_of_subtitles ); diff --git a/mencoder.c b/mencoder.c index c87938a3fb..fe160afce1 100644 --- a/mencoder.c +++ b/mencoder.c @@ -143,6 +143,7 @@ int out_file_format=MUXER_TYPE_AVI; // default to AVI //void resync_audio_stream(sh_audio_t *sh_audio){} int verbose=0; // must be global! +int identify=0; int quiet=0; double video_time_usage=0; double vout_time_usage=0; diff --git a/mp_msg.h b/mp_msg.h index d8c5ce44be..1e999563ae 100644 --- a/mp_msg.h +++ b/mp_msg.h @@ -2,7 +2,9 @@ #ifndef _MP_MSG_H #define _MP_MSG_H -extern int verbose; // defined in mplayer.c +// defined in mplayer.c and mencoder.c +extern int verbose; +extern int identify; // verbosity elevel: diff --git a/mplayer.c b/mplayer.c index e7f5fc7d55..3a171ef221 100644 --- a/mplayer.c +++ b/mplayer.c @@ -760,6 +760,11 @@ void add_subtitles(char *filename, float fps, int silent) mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadSub, filename); if (subd == NULL || set_of_sub_size >= MAX_SUBTITLE_FILES) return; set_of_subtitles[set_of_sub_size] = subd; + if (identify) + { + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_FILE_SUB_ID=%d\n", set_of_sub_size); + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_FILE_SUB_FILENAME=%s\n", filename); + } ++set_of_sub_size; mp_msg(MSGT_FIXME, MSGL_FIXME, MSGTR_AddedSubtitleFile, set_of_sub_size, filename); } diff --git a/vobsub.c b/vobsub.c index 3135952265..9dfe49e41d 100644 --- a/vobsub.c +++ b/vobsub.c @@ -656,6 +656,12 @@ vobsub_add_id(vobsub_t *vob, const char *id, size_t idlen, const unsigned int in memcpy(vob->spu_streams[index].id, id, idlen); } vob->spu_streams_current = index; + if (identify) + { + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VOBSUB_ID=%d\n", index); + if (id && idlen) + mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VSID_%d_LANG=%s\n", index, vob->spu_streams[index].id); + } mp_msg(MSGT_VOBSUB,MSGL_V,"[vobsub] subtitle (vobsubid): %d language %s\n", index, vob->spu_streams[index].id); return 0; -- cgit v1.2.3