diff options
author | John Stebbins <[email protected]> | 2016-12-15 09:36:13 -0800 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-12-15 15:18:55 -0800 |
commit | 7e8119993caafec4cfa8aa5805bf5b23c6ce0195 (patch) | |
tree | 4640f5905d4abe1cb9eaf32fe859b0c3e6ebbd40 /test | |
parent | d6562bb71ed6d00608c0415f74e9d1c5ef09e019 (diff) |
CLI: allow overriding automatically selected "default" subtitle
Diffstat (limited to 'test')
-rw-r--r-- | test/test.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/test/test.c b/test/test.c index d5e1ea4ef..502645573 100644 --- a/test/test.c +++ b/test/test.c @@ -1663,12 +1663,14 @@ static void ShowHelp() " the subtitle list specified with '--subtitle'\n" " or \"native\" to burn the subtitle track that may\n" " be added by the 'native-language' option.\n" -" --subtitle-default[=number]\n" +" --subtitle-default[=number or \"none\"]\n" " Flag the selected subtitle as the default\n" " subtitle to be displayed upon playback. Setting\n" " no default means no subtitle will be displayed\n" " automatically. 'number' is an index into the\n" " subtitle list specified with '--subtitle'.\n" +" \"none\" may be used to override an automatically\n" +" selected default subtitle track.\n" " -N, --native-language <string>\n" " Specifiy your language preference. When the first\n" " audio track does not match your native language\n" @@ -2338,7 +2340,14 @@ static int ParseOptions( int argc, char ** argv ) case SUB_DEFAULT: if (optarg != NULL) { - subdefault = strtol(optarg, NULL, 0); + if (!strcasecmp("none", optarg)) + { + subdefault = -1; + } + else + { + subdefault = strtol(optarg, NULL, 0); + } } else { @@ -4482,14 +4491,23 @@ PrepareJob(hb_handle_t *h, hb_title_t *title, hb_dict_t *preset_dict) } else { - if (subdefault > 0) + if (subdefault || srtdefault > 0) { // "Default" flag can not be applied till after subtitles have // been selected. Apply it here if subtitle selection was // made by the preset. hb_value_t *sub_dict = hb_dict_get(job_dict, "Subtitle"); hb_value_t *sub_list = hb_dict_get(sub_dict, "SubtitleList"); - if (hb_value_array_len(sub_list) >= subdefault) + int ii; + + // disable any currently set default flag + for (ii = 0; ii < hb_value_array_len(sub_list); ii++) + { + hb_value_t *sub = hb_value_array_get(sub_list, ii); + hb_dict_set(sub, "Default", hb_value_bool(0)); + } + + if (subdefault > 0 && hb_value_array_len(sub_list) >= subdefault) { hb_value_t *sub = hb_value_array_get(sub_list, subdefault - 1); hb_dict_set(sub, "Default", hb_value_bool(1)); |