diff --git a/ChangeLog b/ChangeLog index 595346605..e1b0be80c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2004-01-17 Moritz Bunkus + * mkvmerge/mmg: allow the track names to be empty so that you can + remove them when muxing Matroska files. Same for the file title. + * mkvmerge: new feature: The track headers will be rendered completely including the elements that are set to their default values. Causes less confusion and allows the setting of e.g. the diff --git a/src/input/r_matroska.cpp b/src/input/r_matroska.cpp index 75c864f9d..59583896f 100644 --- a/src/input/r_matroska.cpp +++ b/src/input/r_matroska.cpp @@ -1533,8 +1533,10 @@ void kax_reader_c::create_packetizers() { create_packetizer((*ti->track_order)[i]); for (i = 0; i < tracks.size(); i++) create_packetizer(tracks[i]->tnum); - if (segment_title.length() == 0) + if (segment_title_set == false) { segment_title = title; + segment_title_set = true; + } } // }}} diff --git a/src/mkvmerge.cpp b/src/mkvmerge.cpp index 9aeaee8e7..6e809dff5 100644 --- a/src/mkvmerge.cpp +++ b/src/mkvmerge.cpp @@ -178,6 +178,7 @@ char *chapter_language = NULL; char *chapter_charset = NULL; string segment_title; +bool segment_title_set = false; int64_t tags_size = 0; bool accept_tags = true; @@ -843,7 +844,7 @@ static void parse_language(char *s, language_t &lang, const char *opt, mxerror("Invalid track ID specified in '--%s %s'.\n", opt, orig.c_str()); s = &colon[1]; - if (*s == 0) + if (check && (*s == 0)) mxerror("Invalid %s specified in '--%s %s'.\n", topic, opt, orig.c_str()); if (check && !is_valid_iso639_2_code(s)) @@ -1370,11 +1371,12 @@ static void parse_args(int argc, char **argv) { else if (!strcmp(this_arg, "--title")) { char *tmp; - if ((next_arg == NULL) || (next_arg[0] == 0)) + if (next_arg == NULL) mxerror("'--title' lacks the title.\n"); tmp = to_utf8(cc_command_line, next_arg); segment_title = tmp; + segment_title_set = true; safefree(tmp); i++; @@ -1857,6 +1859,12 @@ static char **read_args_from_file(int &num_args, char **args, char *filename) { while (!mm_io->eof() && mm_io->getline2(buffer)) { strip(buffer); + + if (buffer == "#EMPTY#") { + args = add_string(num_args, args, ""); + continue; + } + if ((buffer[0] == '#') || (buffer[0] == 0)) continue; diff --git a/src/mkvmerge.h b/src/mkvmerge.h index 63fc09d70..2cfe73be1 100644 --- a/src/mkvmerge.h +++ b/src/mkvmerge.h @@ -47,6 +47,7 @@ extern KaxChapters *kax_chapters; extern int track_number; extern int64_t tags_size; extern string segment_title; +extern bool segment_title_set; extern float video_fps; diff --git a/src/mmg/mmg.cpp b/src/mmg/mmg.cpp index afc255e97..bd106133f 100644 --- a/src/mmg/mmg.cpp +++ b/src/mmg/mmg.cpp @@ -699,7 +699,7 @@ void mmg_dialog::update_command_line() { clargs.Add(arg); } - if (t->track_name->Length() > 0) { + if ((t->track_name->Length() > 0) || t->track_name_was_present) { cmdline += "--track-name \"" + sid + ":" + shell_escape(*t->track_name) + "\" "; clargs.Add("--track-name"); @@ -834,6 +834,10 @@ void mmg_dialog::update_command_line() { shell_escape(global_page->tc_title->GetValue()) + "\" "; clargs.Add("--title"); clargs.Add(global_page->tc_title->GetValue()); + } else if (title_was_present) { + cmdline += "--title \"\""; + clargs.Add("--title"); + clargs.Add(""); } if (global_page->cb_split->IsChecked()) { diff --git a/src/mmg/mmg.h b/src/mmg/mmg.h index ee59ee374..bdb9bfbde 100644 --- a/src/mmg/mmg.h +++ b/src/mmg/mmg.h @@ -183,6 +183,7 @@ typedef struct { bool enabled, display_dimensions_selected; bool default_track, aac_is_sbr; + bool track_name_was_present; wxString *language, *track_name, *cues, *delay, *stretch, *sub_charset; wxString *tags, *fourcc, *aspect_ratio, *compression, *timecodes; wxString *dwidth, *dheight; @@ -190,6 +191,7 @@ typedef struct { typedef struct { wxString *file_name, *title; + bool title_was_present; int container; vector *tracks; bool no_chapters, no_attachments, no_tags; @@ -208,6 +210,7 @@ extern vector files; extern vector attachments; extern wxArrayString sorted_charsets; extern wxArrayString sorted_iso_codes; +extern bool title_was_present; wxString &break_line(wxString &line, int break_after = 80); wxString extract_language_code(wxString source); diff --git a/src/mmg/mux_dialog.cpp b/src/mmg/mux_dialog.cpp index 2dcf163c1..588f94615 100644 --- a/src/mmg/mux_dialog.cpp +++ b/src/mmg/mux_dialog.cpp @@ -100,23 +100,6 @@ mux_dialog::mux_dialog(wxWindow *parent): process = new mux_process(this); -// #ifdef SYS_UNIX -// int i; -// wxArrayString &arg_list = -// static_cast(parent)->get_command_line_args(); -// char **args = (char **)safemalloc((arg_list.Count() + 1) * sizeof(char *)); -// for (i = 0; i < arg_list.Count(); i++) -// args[i] = safestrdup(arg_list[i].c_str()); -// args[i] = NULL; - -// pid = wxExecute(args, wxEXEC_ASYNC, process); -// for (i = 0; i < arg_list.Count(); i++) -// safefree(args[i]); -// safefree(args); -// #else -// pid = wxExecute(static_cast(parent)->get_command_line(), -// wxEXEC_ASYNC, process); -// #endif #if defined(SYS_WINDOWS) opt_file_name.Printf("mmg-mkvmerge-options-%d-%d", (int)GetCurrentProcessId(), (int)time(NULL)); @@ -137,7 +120,10 @@ mux_dialog::mux_dialog(wxWindow *parent): } arg_list = &static_cast(parent)->get_command_line_args(); for (i = 1; i < arg_list->Count(); i++) { - opt_file->puts_unl((*arg_list)[i].c_str()); + if ((*arg_list)[i].Length() == 0) + opt_file->puts_unl("#EMPTY#"); + else + opt_file->puts_unl((*arg_list)[i].c_str()); opt_file->puts_unl("\n"); } delete opt_file; diff --git a/src/mmg/tab_input.cpp b/src/mmg/tab_input.cpp index a73de2047..e3448fdc7 100644 --- a/src/mmg/tab_input.cpp +++ b/src/mmg/tab_input.cpp @@ -38,6 +38,7 @@ using namespace std; wxArrayString sorted_iso_codes; wxArrayString sorted_charsets; +bool title_was_present = false; tab_input::tab_input(wxWindow *parent): wxPanel(parent, -1, wxDefaultPosition, wxSize(100, 400), @@ -522,9 +523,10 @@ void tab_input::on_add_file(wxCommandEvent &evt) { pair = split(args[k].c_str(), ":", 2); if (pair.size() != 2) continue; - if (pair[0] == "track_name") + if (pair[0] == "track_name") { *track.track_name = unescape(pair[1].c_str()).c_str(); - else if (pair[0] == "language") + track.track_name_was_present = true; + } else if (pair[0] == "language") *track.language = unescape(pair[1].c_str()).c_str(); } } @@ -569,8 +571,10 @@ void tab_input::on_add_file(wxCommandEvent &evt) { args = split(info.c_str(), " "); for (k = 0; k < args.size(); k++) { pair = split(args[k].c_str(), ":", 2); - if ((pair.size() == 2) && (pair[0] == "title")) + if ((pair.size() == 2) && (pair[0] == "title")) { *file.title = unescape(pair[1].c_str()).c_str(); + title_was_present = true; + } } } } diff --git a/src/pr_generic.cpp b/src/pr_generic.cpp index debea99f8..8ef1c16c7 100644 --- a/src/pr_generic.cpp +++ b/src/pr_generic.cpp @@ -537,7 +537,7 @@ void generic_packetizer_c::set_headers() { *(static_cast (&GetChild(*track_entry))) = "eng"; - if (ti->track_name != NULL) + if ((ti->track_name != NULL) && (ti->track_name[0] != 0)) *(static_cast (&GetChild(*track_entry))) = cstrutf8_to_UTFstring(ti->track_name);