Commit 1f074202 authored by Bernie Purcell's avatar Bernie Purcell

Select subtitle stream from the mkv container automatically

if it has a DEFAULT flag on it. User overrides for
preferred language should continue to take precedence.
The current versions of MKVToolnix correctly support DEFAULT
track tag but some older versions don't. If you want to have
subtitle streams in your mkv file, but not have them activate
by default, try remuxing any files causing you trouble, with
the current version of MKVToolnix, and turning the DEFAULT
track flag option to NO for all subtitles streams.
MKVToolnix is available from http://www.bunkus.org/videotools/mkvtoolnix/
parent 8b0e6890
......@@ -55,6 +55,9 @@ enum es_out_query_e
/* set es selected for the es category(audio/video/spu) */
ES_OUT_SET_ES, /* arg1= es_out_id_t* */
/* set 'default' tag on es (copied across from container) */
ES_OUT_SET_DEFAULT, /* arg1= es_out_id_t* */
/* force selection/unselection of the ES (bypass current mode)*/
ES_OUT_SET_ES_STATE,/* arg1= es_out_id_t* arg2=vlc_bool_t */
ES_OUT_GET_ES_STATE,/* arg1= es_out_id_t* arg2=vlc_bool_t* */
......
......@@ -2619,6 +2619,18 @@ bool matroska_segment_c::Select( mtime_t i_start_time )
tracks[i_track]->p_es = es_out_Add( sys.demuxer.out, &tracks[i_track]->fmt );
/* Turn on a subtitles track if it has been flagged as default -
* but only do this if no subtitles track has already been engaged,
* either by an earlier 'default track' (??) or by default
* language choice behaviour.
*/
if( tracks[i_track]->b_default )
{
es_out_Control( sys.demuxer.out,
ES_OUT_SET_DEFAULT,
tracks[i_track]->p_es );
}
es_out_Control( sys.demuxer.out, ES_OUT_SET_NEXT_DISPLAY_TIME, tracks[i_track]->p_es, i_start_time );
}
......
......@@ -108,6 +108,7 @@ struct es_out_sys_t
/* es to select */
int i_audio_last, i_audio_id;
int i_sub_last, i_sub_id;
int i_default_sub_id; /* As specified in container; if applicable */
char **ppsz_audio_language;
char **ppsz_sub_language;
......@@ -179,6 +180,8 @@ es_out_t *input_EsOutNew( input_thread_t *p_input )
var_Get( p_input, "sub-track", &val );
p_sys->i_sub_last = val.i_int;
p_sys->i_default_sub_id = -1;
if( !p_input->b_preparsing )
{
var_Get( p_input, "audio-language", &val );
......@@ -1128,6 +1131,12 @@ static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force )
i_wanted = es->i_channel;
}
else if( p_sys->i_default_sub_id >= 0 )
{
if( es->i_id == p_sys->i_default_sub_id )
i_wanted = es->i_channel;
}
if( p_sys->i_sub_last >= 0 )
i_wanted = p_sys->i_sub_last;
......@@ -1491,6 +1500,42 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
pl_Release( p_playlist );
}
return VLC_SUCCESS;
case ES_OUT_SET_DEFAULT:
{
es = (es_out_id_t*) va_arg( args, es_out_id_t * );
if( es == NULL )
{
/*p_sys->i_default_video_id = -1;*/
/*p_sys->i_default_audio_id = -1;*/
p_sys->i_default_sub_id = -1;
}
else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) )
{
/*p_sys->i_default_video_id = -1;*/
}
else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) )
{
/*p_sys->i_default_audio_id = -1;*/
}
else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) )
{
p_sys->i_default_sub_id = -1;
}
else
{
/*if( es->fmt.i_cat == VIDEO_ES )
p_sys->i_default_video_id = es->i_id;
else
if( es->fmt.i_cat == AUDIO_ES )
p_sys->i_default_audio_id = es->i_id;
else*/
if( es->fmt.i_cat == SPU_ES )
p_sys->i_default_sub_id = es->i_id;
}
return VLC_SUCCESS;
}
case ES_OUT_SET_PCR:
case ES_OUT_SET_GROUP_PCR:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment