private static void MatroskaTagsDescriptor(EbmlReader ebmlReader, MatroskaElementDescriptorProvider medp, string tab) { //Console.WriteLine("\t " + (ebmlReader.ElementSize)); while (ebmlReader.ReadNext()) { var descriptor = medp.GetElementDescriptor(ebmlReader.ElementId); if (descriptor == null) continue; if (descriptor.Name == "Cluster") continue; if (descriptor.Name == "Cues") continue; Console.WriteLine(tab + descriptor.Name + " " + ebmlReader.ElementPosition); if (descriptor.Type == ElementType.MasterElement) { ebmlReader.EnterContainer(); MatroskaTagsDescriptor(ebmlReader, medp, tab + "\t"); } } ebmlReader.LeaveContainer(); }
// Hierarchie des tags du conteneur MKV public static void MatroskaTagsIndentator(string mkvFilePath) { MatroskaElementDescriptorProvider medp = new MatroskaElementDescriptorProvider(); using (var fs = new FileStream(mkvFilePath, FileMode.Open, FileAccess.Read)) using (EbmlReader ebmlReader = new EbmlReader(fs)) { var segmentFound = ebmlReader.LocateElement(MatroskaElementDescriptorProvider.Segment); if (segmentFound) { ebmlReader.EnterContainer(); MatroskaTagsDescriptor(ebmlReader, medp, ""); } } }
private void GetMatroskaTags() { MatroskaElementDescriptorProvider medp = new MatroskaElementDescriptorProvider(); using (var fs = new FileStream(path + "/" + fullName, FileMode.Open, FileAccess.Read)) using (EbmlReader ebmlReader = new EbmlReader(fs)) { //Console.WriteLine("--------------" + labelName + "----------------"); var segmentFound = ebmlReader.LocateElement(MatroskaElementDescriptorProvider.Segment); if (segmentFound) { ebmlReader.EnterContainer(); while (ebmlReader.ReadNext()) { var descriptor = medp.GetElementDescriptor(ebmlReader.ElementId); if (descriptor == null) continue; if (descriptor.Name == "Tracks") { ebmlReader.EnterContainer(); while (ebmlReader.ReadNext()) { var trackDescriptor = medp.GetElementDescriptor(ebmlReader.ElementId); if (trackDescriptor == null) continue; if (trackDescriptor.Name == "TrackEntry") { ebmlReader.EnterContainer(); long trackType = 0; string trackLanguage = null; while (ebmlReader.ReadNext()) { var trackEntryDescriptor = medp.GetElementDescriptor(ebmlReader.ElementId); if (trackEntryDescriptor == null) continue; if (trackEntryDescriptor.Name == "Video") { ebmlReader.EnterContainer(); while (ebmlReader.ReadNext()) { var videoDescriptor = medp.GetElementDescriptor(ebmlReader.ElementId); if (videoDescriptor == null) continue; if (videoDescriptor.Name == "PixelWidth") { width = ebmlReader.ReadInt(); } else if (videoDescriptor.Name == "PixelHeight") { height = ebmlReader.ReadInt(); } } ebmlReader.LeaveContainer(); } else if (trackEntryDescriptor.Name == "TrackType") { trackType = ebmlReader.ReadInt(); } else if (trackEntryDescriptor.Name == "Language") { trackLanguage = ebmlReader.ReadUtf(); if (trackType == 0x11) //subtitle { listLanguageSubtitle.Add(trackLanguage); //Console.WriteLine("subtitle : ->" + trackLanguage + "<-"); } else if (trackType == 2) //audio { listLanguageAudio.Add(trackLanguage); //Console.WriteLine("audio : ->" + trackLanguage + "<-"); } } } ebmlReader.LeaveContainer(); } } ebmlReader.LeaveContainer(); break; } } } } }