# HG changeset patch # User ib # Date 1391368711 0 # Node ID 68794f2fbf1e732346ed27afd42529f67c106cdb # Parent c3962450b00bb6f74ef62282839d997335ffd4ae Add support for default of multiple video tracks. Some container formats like matroska support multiple video tracks, one of which may be flagged the 'default' one which thus should be played by default. Works with the lavf demuxer. diff -r c3962450b00b -r 68794f2fbf1e libmpdemux/demux_lavf.c --- a/libmpdemux/demux_lavf.c Sun Feb 02 10:54:37 2014 +0000 +++ b/libmpdemux/demux_lavf.c Sun Feb 02 19:18:31 2014 +0000 @@ -403,6 +403,8 @@ sh_video->i_bps=codec->bit_rate/8; if (title && title->value) mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VID_%d_NAME=%s\n", priv->video_streams, title->value); + if (st->disposition & AV_DISPOSITION_DEFAULT) + sh_video->default_track = 1; if (rot && rot->value) mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VID_%d_ROTATE=%s\n", priv->video_streams, rot->value); mp_msg(MSGT_DEMUX,MSGL_DBG2,"aspect= %d*%d/(%d*%d)\n", diff -r c3962450b00b -r 68794f2fbf1e libmpdemux/demuxer.c --- a/libmpdemux/demuxer.c Sun Feb 02 10:54:37 2014 +0000 +++ b/libmpdemux/demuxer.c Sun Feb 02 19:18:31 2014 +0000 @@ -1916,6 +1916,22 @@ return -1; } +int demuxer_default_video_track(demuxer_t *d) +{ + int i; + for (i = 0; i < MAX_V_STREAMS; ++i) { + sh_video_t *sh = d->v_streams[i]; + if (sh && sh->default_track) + return sh->vid; + } + for (i = 0; i < MAX_V_STREAMS; ++i) { + sh_video_t *sh = d->v_streams[i]; + if (sh) + return sh->vid; + } + return -1; +} + int demuxer_default_sub_track(demuxer_t *d) { int i; diff -r c3962450b00b -r 68794f2fbf1e libmpdemux/demuxer.h --- a/libmpdemux/demuxer.h Sun Feb 02 10:54:37 2014 +0000 +++ b/libmpdemux/demuxer.h Sun Feb 02 19:18:31 2014 +0000 @@ -486,6 +486,7 @@ // for subtitles, it is the first track with default attribute // for audio, additionally, the first track is selected if no track has default attribute set int demuxer_default_audio_track(demuxer_t* d); +int demuxer_default_video_track(demuxer_t* d); int demuxer_default_sub_track(demuxer_t* d); #endif /* MPLAYER_DEMUXER_H */ diff -r c3962450b00b -r 68794f2fbf1e mencoder.c --- a/mencoder.c Sun Feb 02 10:54:37 2014 +0000 +++ b/mencoder.c Sun Feb 02 19:18:31 2014 +0000 @@ -709,10 +709,10 @@ 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); + video_id = prog.vid; // switching is handled by select_video below } } + select_video(demuxer, video_id); select_audio(demuxer, audio_id, audio_lang); if (dvdsub_id == -1 && dvdsub_lang) diff -r c3962450b00b -r 68794f2fbf1e mpcommon.c --- a/mpcommon.c Sun Feb 02 10:54:37 2014 +0000 +++ b/mpcommon.c Sun Feb 02 19:18:31 2014 +0000 @@ -416,6 +416,16 @@ return demuxer->audio->id; } +int select_video(demuxer_t* demuxer, int video_id) +{ + if (video_id == -1) + video_id = demuxer_default_video_track(demuxer); + if (video_id != -1) // -1 (automatic) is the default behaviour of demuxers + demuxer_switch_video(demuxer, video_id); + + return demuxer->video->id; +} + /* Parse -noconfig common to both programs */ int disable_system_conf=0; int disable_user_conf=0; diff -r c3962450b00b -r 68794f2fbf1e mpcommon.h --- a/mpcommon.h Sun Feb 02 10:54:37 2014 +0000 +++ b/mpcommon.h Sun Feb 02 19:18:31 2014 +0000 @@ -75,6 +75,7 @@ void update_subtitles(struct sh_video *sh_video, double refpts, demux_stream_t *d_dvdsub, int reset); void update_teletext(struct sh_video *sh_video, demuxer_t *demuxer, int reset); int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang); +int select_video(demuxer_t* demuxer, int video_id); void set_osd_subtitle(subtitle *subs); int cfg_inc_verbose(m_option_t *conf); diff -r c3962450b00b -r 68794f2fbf1e mplayer.c --- a/mplayer.c Sun Feb 02 10:54:37 2014 +0000 +++ b/mplayer.c Sun Feb 02 19:18:31 2014 +0000 @@ -3458,6 +3458,10 @@ int tmp = ts_prog; mp_property_do("switch_program", M_PROPERTY_SET, &tmp, mpctx); } + + // select video stream + select_video(mpctx->demuxer, video_id); + // select audio stream select_audio(mpctx->demuxer, audio_id, audio_lang);