diff --git a/ChangeLog b/ChangeLog index 350ff0259..38f4517a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-08-19 Moritz Bunkus + * mkvmerge: enhancement: mmg outputs a more informative error + message for known but unsupported input file types (e.g. ASF, FLV, + MPEG TS) instead of the cryptic "file identification failed". + * mkvmerge: bug fix: The VobSub reader would sometimes read too many bytes for a single SPU packet. Part of a fix for bug 245. diff --git a/src/input/r_asf.cpp b/src/input/r_asf.cpp index e1b897f69..a495a0f01 100644 --- a/src/input/r_asf.cpp +++ b/src/input/r_asf.cpp @@ -33,7 +33,7 @@ asf_reader_c::probe_file(mm_io_c *io, io->setFilePointer(0, seek_beginning); if (get_uint32_be(buf) == 0x3026b275) { - mxerror(mxsprintf("The file '%s' is an ASF/WMV container which is not supported by mkvmerge.\n", io->get_file_name().c_str()).c_str()); + id_result_container_unsupported(io->get_file_name(), "Windows Media (ASF/WMV)"); // Never reached: return 1; } diff --git a/src/input/r_flac.cpp b/src/input/r_flac.cpp index 99a481c87..4a8ea2ee7 100644 --- a/src/input/r_flac.cpp +++ b/src/input/r_flac.cpp @@ -589,7 +589,7 @@ flac_reader_c::probe_file(mm_io_c *io, } if (strncmp((char *)data, "fLaC", 4)) return 0; - mxerror("mkvmerge has not been compiled with FLAC support.\n"); + id_result_container_unsupported(io->get_file_name(), "FLAC"); return 1; } diff --git a/src/input/r_flac.h b/src/input/r_flac.h index 35e69a000..559f3bde3 100644 --- a/src/input/r_flac.h +++ b/src/input/r_flac.h @@ -102,9 +102,12 @@ protected: #else // HAVE_FLAC_FORMAT_H -class flac_reader_c { +class flac_reader_c: public generic_reader_c { public: static int probe_file(mm_io_c *file, int64_t size); + +public: + flac_reader_c(track_info_c &n_ti): generic_reader_c(n_ti) { }; }; #endif // HAVE_FLAC_FORMAT_H diff --git a/src/input/r_flv.cpp b/src/input/r_flv.cpp index f85814f01..b8cf52957 100644 --- a/src/input/r_flv.cpp +++ b/src/input/r_flv.cpp @@ -33,7 +33,7 @@ flv_reader_c::probe_file(mm_io_c *io, io->setFilePointer(0, seek_beginning); if (!memcmp(buf, "FLV", 3)) { - mxerror(mxsprintf("The file '%s' is a Macromedia Flash Video (FLV) container which is not supported by mkvmerge.\n", io->get_file_name().c_str()).c_str()); + id_result_container_unsupported(io->get_file_name(), "Macromedia Flash Video (FLV)"); // Never reached: return 1; } diff --git a/src/input/r_mpeg.cpp b/src/input/r_mpeg.cpp index 7b999d793..5b09ff172 100644 --- a/src/input/r_mpeg.cpp +++ b/src/input/r_mpeg.cpp @@ -1380,8 +1380,11 @@ mpeg_ts_reader_c::probe_file(mm_io_c *io, ++num_startcodes; } - if (TS_CONSECUTIVE_PACKETS <= num_startcodes) + if (TS_CONSECUTIVE_PACKETS <= num_startcodes) { + id_result_container_unsupported(io->get_file_name(), "MPEG Transport Stream (TS)"); + // Never reached: return true; + } } } diff --git a/src/input/r_mpeg.h b/src/input/r_mpeg.h index e6fcc223d..ffbe7edc1 100644 --- a/src/input/r_mpeg.h +++ b/src/input/r_mpeg.h @@ -163,12 +163,15 @@ private: void init_reader(); }; -class mpeg_ts_reader_c { +class mpeg_ts_reader_c: public generic_reader_c { protected: static int potential_packet_sizes[]; public: static bool probe_file(mm_io_c *io, int64_t size); + +public: + mpeg_ts_reader_c(track_info_c &n_ti): generic_reader_c(n_ti) { }; }; #endif // __R_MPEG_H diff --git a/src/merge/mkvmerge.cpp b/src/merge/mkvmerge.cpp index 10c582f0f..8f353f205 100644 --- a/src/merge/mkvmerge.cpp +++ b/src/merge/mkvmerge.cpp @@ -359,14 +359,14 @@ identify(const string &filename) { track_info_c ti; filelist_t file; - file.name = filename; - get_file_type(file); - ti.fname = file.name; + verbose = 0; + suppress_warnings = true; + identifying = true; + file.name = filename; - if (FILE_TYPE_MPEG_TS == file.type) - mxerror(_("The file '%s' has been detected as a MPEG transport stream. " - "This file format is not supported by mkvmerge.\n"), - file.name.c_str()); + get_file_type(file); + + ti.fname = file.name; if (file.type == FILE_TYPE_IS_UNKNOWN) mxerror(_("File %s has unknown type. Please have a look " @@ -379,9 +379,6 @@ identify(const string &filename) { files.push_back(file); - verbose = 0; - identifying = true; - suppress_warnings = true; create_readers(); files[0].reader->identify(); diff --git a/src/merge/pr_generic.cpp b/src/merge/pr_generic.cpp index 432ceb3dc..20b824aec 100644 --- a/src/merge/pr_generic.cpp +++ b/src/merge/pr_generic.cpp @@ -1400,6 +1400,16 @@ generic_reader_c::flush_packetizers() { (*it)->flush(); } +void +generic_reader_c::id_result_container_unsupported(const string &filename, + const string &info) { + if (identifying) { + mxinfo("File '%s': unsupported container: %s\n", filename.c_str(), info.c_str()); + mxexit(3); + } else + mxerror("The file '%s' is a non-supported file type (%s).\n", filename.c_str(), info.c_str()); +} + void generic_reader_c::id_result_container(const string &info, const string &verbose_info) { diff --git a/src/merge/pr_generic.h b/src/merge/pr_generic.h index 6976235a4..cd0285952 100644 --- a/src/merge/pr_generic.h +++ b/src/merge/pr_generic.h @@ -296,6 +296,8 @@ protected: virtual void id_result_track(int64_t track_id, const string &type, const string &info, const string &verbose_info = empty_string); virtual void id_result_track(int64_t track_id, const string &type, const string &info, const vector &verbose_info); virtual void id_result_attachment(int64_t attachment_id, const string &type, int size, const string &file_name = empty_string, const string &description = empty_string); + + static void id_result_container_unsupported(const string &filename, const string &info); }; enum connection_result_e { diff --git a/src/mmg/tab_input.cpp b/src/mmg/tab_input.cpp index c4e928a2e..6a906d3f8 100644 --- a/src/mmg/tab_input.cpp +++ b/src/mmg/tab_input.cpp @@ -365,7 +365,21 @@ tab_input::add_file(const wxString &file_name, wxLogMessage(wxT("identify 1: errors[%d]: ``%s''"), i, errors[i].c_str()); wxRemoveFile(opt_file_name); - if ((result < 0) || (result > 1)) { + + if (3 == result) { + wxString container = wxT("unknown"); + + if (output.Count() && (0 <= (pos = output[0].Find(wxT("container:"))))) + container = output[0].Mid(pos + 11); + + wxString info; + info.Printf(wxT("The file is an unsupported container format (%s)."), container.c_str()); + break_line(info, 60); + + wxMessageBox(info, wxT("Unsupported format"), wxOK | wxCENTER | wxICON_ERROR); + return; + + } else if ((0 > result) || (1 < result)) { name.Printf(wxT("File identification failed for '%s'. Return code: " "%d\n\n"), file_name.c_str(), result); for (i = 0; i < output.Count(); i++) @@ -376,7 +390,8 @@ tab_input::add_file(const wxString &file_name, wxMessageBox(name, wxT("File identification failed"), wxOK | wxCENTER | wxICON_ERROR); return; - } else if (result > 0) { + + } else if (0 < result) { name.Printf(wxT("File identification failed. Return code: %d. Errno: %d " "(%s). Make sure that you've selected a mkvmerge " "executable on the 'settings' tab."), result, errno,