Added a new warning if there is no corresponding track in a source file for a track UID used on the command line.

This commit is contained in:
Moritz Bunkus 2004-10-04 19:18:25 +00:00
parent ed36adc166
commit 469b69f5c0
15 changed files with 134 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2004-10-04 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: new feature: Added two warnings. One about invalid
track IDs that were used on the command line but that don't
correspond to an available track in a file and one if no track
will be copied from a source file. Both warnings hint at bad
command line arguments.
2004-10-03 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: Only write the segment duration as a 64bit float if

View File

@ -607,4 +607,13 @@ avi_reader_c::identify() {
}
}
void
avi_reader_c::add_available_track_ids() {
int i;
// Yes, this is correct. Don't forget the video track!
for (i = 0; i <= AVI_audio_tracks(avi); i++)
available_track_ids.push_back(i);
}
// }}}

View File

@ -62,6 +62,7 @@ public:
virtual void identify();
virtual void create_packetizers();
virtual void create_packetizer(int64_t tid);
virtual void add_available_track_ids();
static int probe_file(mm_io_c *mm_io, int64_t size);

View File

@ -2194,3 +2194,11 @@ kax_reader_c::flush_packetizers() {
PTZR(tracks[i]->ptzr)->flush();
}
void
kax_reader_c::add_available_track_ids() {
int i;
for (i = 0; i < tracks.size(); i++)
available_track_ids.push_back(tracks[i]->tnum);
}

View File

@ -142,6 +142,7 @@ public:
virtual void create_packetizers();
virtual void create_packetizer(int64_t tid);
virtual void add_attachments(KaxAttachments *a);
virtual void add_available_track_ids();
static int probe_file(mm_io_c *mm_io, int64_t size);

View File

@ -1247,3 +1247,12 @@ ogm_reader_c::handle_stream_comments() {
free_string_array(comments);
}
}
void
ogm_reader_c::add_available_track_ids() {
int i;
for (i = 0; i < sdemuxers.size(); i++)
available_track_ids.push_back(i);
}

View File

@ -110,6 +110,7 @@ public:
virtual void identify();
virtual void create_packetizers();
virtual void create_packetizer(int64_t tid);
virtual void add_available_track_ids();
virtual int display_priority();
virtual void display_progress(bool final = false);

View File

@ -1274,3 +1274,11 @@ qtmp4_reader_c::flush_packetizers() {
if (demuxers[i]->ptzr != -1)
PTZR(demuxers[i]->ptzr)->flush();
}
void
qtmp4_reader_c::add_available_track_ids() {
int i;
for (i =0 ; i < demuxers.size(); i++)
available_track_ids.push_back(demuxers[i]->id);
}

View File

@ -126,6 +126,7 @@ public:
virtual void identify();
virtual void create_packetizers();
virtual void create_packetizer(int64_t tid);
virtual void add_available_track_ids();
static int probe_file(mm_io_c *in, int64_t size);

View File

@ -803,3 +803,11 @@ real_reader_c::flush_packetizers() {
if (demuxers[i]->ptzr != -1)
PTZR(demuxers[i]->ptzr)->flush();
}
void
real_reader_c::add_available_track_ids() {
int i;
for (i = 0; i < demuxers.size(); i++)
available_track_ids.push_back(demuxers[i]->track->id);
}

View File

@ -74,6 +74,7 @@ public:
virtual void identify();
virtual void create_packetizers();
virtual void create_packetizer(int64_t tid);
virtual void add_available_track_ids();
static int probe_file(mm_io_c *mm_io, int64_t size);

View File

@ -612,3 +612,11 @@ vobsub_reader_c::flush_packetizers() {
if (tracks[i]->ptzr != -1)
PTZR(tracks[i]->ptzr)->flush();
}
void
vobsub_reader_c::add_available_track_ids() {
int i;
for (i = 0; i < tracks.size(); i++)
available_track_ids.push_back(i);
}

View File

@ -76,6 +76,7 @@ public:
virtual void identify();
virtual void create_packetizers();
virtual void create_packetizer(int64_t tid);
virtual void add_available_track_ids();
static int probe_file(mm_io_c *mm_io, int64_t size);

View File

@ -951,8 +951,8 @@ generic_packetizer_c::parse_ext_timecode_file_v1(mm_io_c *in,
line_no = 1;
do {
if (!in->getline2(line))
mxerror(_("The timecode file '%s' does not contain a valid 'Assume' line "
"with the default number of frames per second.\n"), name);
mxerror(_("The timecode file '%s' does not contain a valid 'Assume' line"
" with the default number of frames per second.\n"), name);
line_no++;
strip(line);
if ((line.length() != 0) && (line[0] != '#'))
@ -1205,10 +1205,37 @@ generic_packetizer_c::handle_avi_audio_sync(int64_t num_bytes,
//--------------------------------------------------------------------
#define add_all_requested_track_ids(container) \
for (i = 0; i < ti->container->size(); i++) \
add_requested_track_id((*ti->container)[i].id);
#define add_all_requested_track_ids2(container) \
for (i = 0; i < ti->container->size(); i++) \
add_requested_track_id((*ti->container)[i]);
generic_reader_c::generic_reader_c(track_info_c *nti) {
int i;
ti = new track_info_c(*nti);
connected_to = NULL;
max_timecode_seen = 0;
add_all_requested_track_ids2(atracks);
add_all_requested_track_ids2(vtracks);
add_all_requested_track_ids2(stracks);
add_all_requested_track_ids(all_fourccs);
add_all_requested_track_ids(display_properties);
add_all_requested_track_ids(audio_syncs);
add_all_requested_track_ids(cue_creations);
add_all_requested_track_ids2(default_track_flags);
add_all_requested_track_ids(languages);
add_all_requested_track_ids(sub_charsets);
add_all_requested_track_ids(all_tags);
add_all_requested_track_ids2(aac_is_sbr);
add_all_requested_track_ids(packet_delays);
add_all_requested_track_ids(compression_list);
add_all_requested_track_ids(track_names);
add_all_requested_track_ids(all_ext_timecodes);
add_all_requested_track_ids(pixel_crop_list);
}
generic_reader_c::~generic_reader_c() {
@ -1316,9 +1343,45 @@ generic_reader_c::display_progress(bool) {
void
generic_reader_c::check_track_ids_and_packetizers() {
int r, a;
bool found;
add_available_track_ids();
if (reader_packetizers.size() == 0)
mxwarn(FMT_FN "No tracks will be copied from this file. This usually "
"indicates a mistake in the command line.\n", ti->fname);
for (r = 0; r < requested_track_ids.size(); r++) {
found = false;
for (a = 0; a < available_track_ids.size(); a++)
if (requested_track_ids[r] == available_track_ids[a]) {
found = true;
break;
}
if (!found)
mxwarn(FMT_FN "A track with the ID %lld was requested but not found "
"in the file. The corresponding option will be ignored.\n",
ti->fname, requested_track_ids[r]);
}
}
void
generic_reader_c::add_requested_track_id(int64_t id) {
int i;
bool found;
if (id == -1)
return;
found = false;
for (i = 0; i < requested_track_ids.size(); i++)
if (requested_track_ids[i] == id) {
found = true;
break;
}
if (!found)
requested_track_ids.push_back(id);
}
//

View File

@ -262,6 +262,7 @@ class generic_reader_c {
public:
track_info_c *ti;
vector<packetizer_container_t> reader_packetizers;
vector<int64_t> requested_track_ids, available_track_ids;
generic_reader_c *connected_to;
int64_t max_timecode_seen;
@ -287,6 +288,10 @@ public:
virtual void set_timecode_offset(int64_t offset);
virtual void check_track_ids_and_packetizers();
virtual void add_requested_track_id(int64_t id);
virtual void add_available_track_ids() {
available_track_ids.push_back(0);
}
protected:
virtual bool demuxing_requested(char type, int64_t id);