Allow the user to un-set track names and the file title when remuxing Matroska files.

This commit is contained in:
Moritz Bunkus 2004-01-17 17:20:20 +00:00
parent e13def97df
commit 6b5bfa9345
9 changed files with 37 additions and 26 deletions

View File

@ -1,5 +1,8 @@
2004-01-17 Moritz Bunkus <moritz@bunkus.org>
* 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

View File

@ -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;
}
}
// }}}

View File

@ -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;

View File

@ -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;

View File

@ -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()) {

View File

@ -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<mmg_track_t> *tracks;
bool no_chapters, no_attachments, no_tags;
@ -208,6 +210,7 @@ extern vector<mmg_file_t> files;
extern vector<mmg_attachment_t> 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);

View File

@ -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<mmg_dialog *>(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<mmg_dialog *>(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<mmg_dialog *>(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;

View File

@ -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;
}
}
}
}

View File

@ -537,7 +537,7 @@ void generic_packetizer_c::set_headers() {
*(static_cast<EbmlString *>
(&GetChild<KaxTrackLanguage>(*track_entry))) = "eng";
if (ti->track_name != NULL)
if ((ti->track_name != NULL) && (ti->track_name[0] != 0))
*(static_cast<EbmlUnicodeString *>
(&GetChild<KaxTrackName>(*track_entry))) =
cstrutf8_to_UTFstring(ti->track_name);