mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-23 19:31:44 +00:00
Renamed a couple of variables ("tracks" -> "tspecs"). Fixed CUE sheet extraction in "tracks" mode. Added a test for the two CUE sheet extraction modes.
This commit is contained in:
parent
cb77d9eff4
commit
e3b2d4ecc5
@ -183,6 +183,9 @@ write_cuesheet(const char *file_name,
|
||||
if (chapters.ListSize() == 0)
|
||||
return;
|
||||
|
||||
if (no_variable_data)
|
||||
file_name = "no-variable-data";
|
||||
|
||||
out.write_bom("UTF-8");
|
||||
|
||||
print_if_global("CATALOG", "CATALOG %s\n"); // until 0.9.6
|
||||
|
@ -58,7 +58,7 @@ extern bool no_variable_data;
|
||||
void show_element(EbmlElement *l, int level, const char *fmt, ...);
|
||||
void show_error(const char *fmt, ...);
|
||||
|
||||
bool extract_tracks(const char *file_name, vector<track_spec_t> &tracks);
|
||||
bool extract_tracks(const char *file_name, vector<track_spec_t> &tspecs);
|
||||
void extract_tags(const char *file_name, bool parse_fully);
|
||||
void extract_chapters(const char *file_name, bool chapter_format_simple,
|
||||
bool parse_fully);
|
||||
|
@ -216,18 +216,18 @@ close_extractors() {
|
||||
static void
|
||||
write_all_cuesheets(KaxChapters &chapters,
|
||||
KaxTags &tags,
|
||||
vector<track_spec_t> &tracks) {
|
||||
vector<track_spec_t> &tspecs) {
|
||||
int i;
|
||||
mm_io_c *out;
|
||||
|
||||
out = NULL;
|
||||
|
||||
for (i = 0; i < tracks.size(); i++) {
|
||||
if (tracks[i].extract_cuesheet) {
|
||||
for (i = 0; i < tspecs.size(); i++) {
|
||||
if (tspecs[i].extract_cuesheet) {
|
||||
string file_name, cue_file_name;
|
||||
int pos, pos2, pos3;
|
||||
|
||||
file_name = tracks[i].out_name;
|
||||
file_name = tspecs[i].out_name;
|
||||
pos = file_name.rfind('/');
|
||||
pos2 = file_name.rfind('\\');
|
||||
if (pos2 > pos)
|
||||
@ -235,7 +235,7 @@ write_all_cuesheets(KaxChapters &chapters,
|
||||
if (pos >= 0)
|
||||
file_name.erase(0, pos2);
|
||||
|
||||
cue_file_name = (string)tracks[i].out_name;
|
||||
cue_file_name = (string)tspecs[i].out_name;
|
||||
pos = cue_file_name.rfind('.');
|
||||
pos2 = cue_file_name.rfind('/');
|
||||
pos3 = cue_file_name.rfind('\\');
|
||||
@ -250,16 +250,40 @@ write_all_cuesheets(KaxChapters &chapters,
|
||||
cue_file_name.c_str(), strerror(errno));
|
||||
}
|
||||
mxinfo(_("The CUE sheet for track %lld will be written to '%s'.\n"),
|
||||
tracks[i].tid, cue_file_name.c_str());
|
||||
write_cuesheet(file_name.c_str(), chapters, tags, tracks[i].tuid, *out);
|
||||
tspecs[i].tid, cue_file_name.c_str());
|
||||
write_cuesheet(file_name.c_str(), chapters, tags, tspecs[i].tuid, *out);
|
||||
delete out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
find_track_uids(KaxTracks &tracks,
|
||||
vector<track_spec_t> &tspecs) {
|
||||
int t;
|
||||
|
||||
for (t = 0; t < tracks.ListSize(); t++) {
|
||||
KaxTrackEntry *track_entry;
|
||||
int64_t track_number;
|
||||
int s;
|
||||
|
||||
track_entry = dynamic_cast<KaxTrackEntry *>(tracks[t]);
|
||||
if (NULL == track_entry)
|
||||
continue;
|
||||
|
||||
track_number = kt_get_number(*track_entry);
|
||||
|
||||
for (s = 0; s < tspecs.size(); s++)
|
||||
if (tspecs[s].tid == track_number) {
|
||||
tspecs[s].tuid = kt_get_uid(*track_entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
extract_tracks(const char *file_name,
|
||||
vector<track_spec_t> &tracks) {
|
||||
vector<track_spec_t> &tspecs) {
|
||||
int upper_lvl_el;
|
||||
// Elements for different levels
|
||||
EbmlElement *l0 = NULL, *l1 = NULL, *l2 = NULL, *l3 = NULL;
|
||||
@ -371,7 +395,8 @@ extract_tracks(const char *file_name,
|
||||
|
||||
tracks_found = true;
|
||||
l1->Read(*es, KaxTracks::ClassInfos.Context, upper_lvl_el, l2, true);
|
||||
create_extractors(*dynamic_cast<KaxTracks *>(l1), tracks);
|
||||
find_track_uids(*dynamic_cast<KaxTracks *>(l1), tspecs);
|
||||
create_extractors(*dynamic_cast<KaxTracks *>(l1), tspecs);
|
||||
|
||||
} else if (EbmlId(*l1) == KaxCluster::ClassInfos.GlobalId) {
|
||||
show_element(l1, 1, _("Cluster"));
|
||||
@ -492,7 +517,7 @@ extract_tracks(const char *file_name,
|
||||
delete es;
|
||||
delete in;
|
||||
|
||||
write_all_cuesheets(all_chapters, all_tags, tracks);
|
||||
write_all_cuesheets(all_chapters, all_tags, tspecs);
|
||||
|
||||
// Now just close the files and go to sleep. Mummy will sing you a
|
||||
// lullaby. Just close your eyes, listen to her sweet voice, singing,
|
||||
|
@ -55,6 +55,16 @@ kt_get_number(KaxTrackEntry &track) {
|
||||
return uint64(*number);
|
||||
}
|
||||
|
||||
int64_t
|
||||
kt_get_uid(KaxTrackEntry &track) {
|
||||
KaxTrackUID *uid;
|
||||
|
||||
uid = FINDFIRST(&track, KaxTrackUID);
|
||||
if (NULL == uid)
|
||||
return 0;
|
||||
return uint64(*uid);
|
||||
}
|
||||
|
||||
string
|
||||
kt_get_codec_id(KaxTrackEntry &track) {
|
||||
KaxCodecID *codec_id;
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
|
||||
int64_t kt_get_default_duration(KaxTrackEntry &track);
|
||||
int64_t kt_get_number(KaxTrackEntry &track);
|
||||
int64_t kt_get_uid(KaxTrackEntry &track);
|
||||
string kt_get_codec_id(KaxTrackEntry &track);
|
||||
int kt_get_max_blockadd_id(KaxTrackEntry &track);
|
||||
|
||||
|
@ -51,3 +51,4 @@ T_201avc_from_mp4_with_par:e8f2d2becffc65592ab541acb8394658:passed:20050125-2245
|
||||
T_202avc_from_mp4_with_par_bframes:7cfd0e522b3b54ebdc987626c18be3a4:passed:20050125-224635
|
||||
T_203wavpack_with_correctiondata:c18786fea4f93d385575aa4b6a0af4ed:passed:20050201-094411
|
||||
T_204wavpack_without_correctiondata:0d01f5162a71fedc934d7e8a675a0004:passed:20050201-094414
|
||||
T_205X_cuesheets:3b00b00c7d185137e30d7e95e3123d33-b3bb67d316e20da12926d5c1d628f6e5:passed:20050210-211853
|
||||
|
20
tests/test-205X_cuesheets.rb
Normal file
20
tests/test-205X_cuesheets.rb
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/ruby -w
|
||||
|
||||
class T_205X_cuesheets < Test
|
||||
def description
|
||||
return "mkvextract / cue sheets / in(MKV)"
|
||||
end
|
||||
|
||||
def run
|
||||
merge("#{tmp}-src", "data/simple/v.mp3 --chapters " +
|
||||
"data/text/cuewithtags2.cue")
|
||||
sys("../src/mkvextract cuesheet #{tmp}-src --no-variable-data &> #{tmp}")
|
||||
hash = hash_tmp(false)
|
||||
sys("../src/mkvextract tracks #{tmp}-src --no-variable-data " +
|
||||
"--cuesheet 1:#{tmp} > /tmp/a")
|
||||
hash += "-" + hash_tmp("#{tmp}.cue")
|
||||
unlink_tmp_files
|
||||
return hash
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user