예제 #1
0
        private String getVideoFileExtensionFromCodecID(gMKVTrack argTrack)
        {
            String outputFileExtension = String.Empty;

            if (argTrack.CodecID.ToUpper().Contains("V_MS/VFW/FOURCC"))
            {
                outputFileExtension = "avi";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_UNCOMPRESSED"))
            {
                outputFileExtension = "raw";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_MPEG4/ISO/"))
            {
                outputFileExtension = "avc";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_MPEGH/ISO/HEVC"))
            {
                outputFileExtension = "hevc";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_MPEG4/MS/V3"))
            {
                outputFileExtension = "mp4";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_MPEG1"))
            {
                outputFileExtension = "mpg";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_MPEG2"))
            {
                outputFileExtension = "mpg";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_REAL/"))
            {
                outputFileExtension = "rm";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_QUICKTIME"))
            {
                outputFileExtension = "mov";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_THEORA"))
            {
                outputFileExtension = "ogg";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_PRORES"))
            {
                outputFileExtension = "mov";
            }
            else if (argTrack.CodecID.ToUpper().Contains("V_VP"))
            {
                outputFileExtension = "ivf";
            }
            else
            {
                outputFileExtension = "mkv";
            }
            return(outputFileExtension);
        }
예제 #2
0
        private String getSubtitleFileExtensionFromCodecID(gMKVTrack argTrack)
        {
            String outputFileExtension = String.Empty;

            if (argTrack.CodecID.ToUpper().Contains("S_TEXT/UTF8"))
            {
                outputFileExtension = "srt";
            }
            else if (argTrack.CodecID.ToUpper().Contains("S_TEXT/SSA"))
            {
                outputFileExtension = "ass";
            }
            else if (argTrack.CodecID.ToUpper().Contains("S_TEXT/ASS"))
            {
                outputFileExtension = "ass";
            }
            else if (argTrack.CodecID.ToUpper().Contains("S_TEXT/USF"))
            {
                outputFileExtension = "usf";
            }
            else if (argTrack.CodecID.ToUpper().Contains("S_IMAGE/BMP"))
            {
                outputFileExtension = "sub";
            }
            else if (argTrack.CodecID.ToUpper().Contains("S_VOBSUB"))
            {
                outputFileExtension = "sub";
            }
            else if (argTrack.CodecID.ToUpper().Contains("S_HDMV/PGS"))
            {
                outputFileExtension = "sup";
            }
            else if (argTrack.CodecID.ToUpper().Contains("S_KATE"))
            {
                outputFileExtension = "ogg";
            }
            else
            {
                outputFileExtension = "sub";
            }
            return(outputFileExtension);
        }
예제 #3
0
        private void ParseMkvMergeOutput()
        {
            // start the loop for each line of the output
            foreach (String outputLine in _MKVMergeOutput.ToString().Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (outputLine.StartsWith("File "))
                {
                    gMKVSegmentInfo tmp = new gMKVSegmentInfo();
                    if (outputLine.Contains("muxing_application:"))
                    {
                        tmp.MuxingApplication = ExtractProperty(outputLine, "muxing_application");
                    }
                    if (outputLine.Contains("writing_application:"))
                    {
                        tmp.WritingApplication = ExtractProperty(outputLine, "writing_application");
                    }
                    if (outputLine.Contains("date_utc:"))
                    {
                        tmp.Date = DateTime.ParseExact(ExtractProperty(outputLine, "date_utc"), formats, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToUniversalTime().
                                   ToString("ddd MMM dd HH:mm:ss yyyy UTC", CultureInfo.InvariantCulture);
                    }
                    if (outputLine.Contains("duration:"))
                    {
                        //Duration: 5979.008s (01:39:39.008)
                        String   originalDuration = ExtractProperty(outputLine, "duration");
                        TimeSpan tmpTime          = TimeSpan.FromMilliseconds(Convert.ToDouble(Int64.Parse(originalDuration)) / 1000000.0);
                        tmp.Duration = String.Format("{0}s ({1}:{2}:{3}.{4})",
                                                     (Convert.ToDouble(Int64.Parse(originalDuration)) / 1000000000.0).ToString("#0.000", CultureInfo.InvariantCulture),
                                                     tmpTime.Hours.ToString("00"),
                                                     tmpTime.Minutes.ToString("00"),
                                                     tmpTime.Seconds.ToString("00"),
                                                     tmpTime.Milliseconds.ToString("000"));
                    }
                    if (!String.IsNullOrEmpty(tmp.MuxingApplication) &&
                        !String.IsNullOrEmpty(tmp.WritingApplication) &&
                        !String.IsNullOrEmpty(tmp.Duration))
                    {
                        _SegmentList.Add(tmp);
                    }
                }
                else if (outputLine.StartsWith("Track ID "))
                {
                    Int32 trackID = Int32.Parse(outputLine.Substring(0, outputLine.IndexOf(":")).Replace("Track ID", String.Empty).Trim());
                    // Check if there is already a track with the same TrackID (workaround for a weird bug in MKVToolnix v4 when identifying files from AviDemux)
                    bool trackFound = false;
                    foreach (gMKVSegment tmpSeg in _SegmentList)
                    {
                        if (tmpSeg is gMKVTrack && ((gMKVTrack)tmpSeg).TrackID == trackID)
                        {
                            // If we already have a track with the same trackID, then don't bother adding it again
                            trackFound = true;
                            break;
                        }
                    }
                    // Check if track found
                    if (trackFound)
                    {
                        // If we already have a track with the same trackID, then don't bother adding it again
                        continue;
                    }
                    gMKVTrack tmp = new gMKVTrack();
                    tmp.TrackType = (MkvTrackType)Enum.Parse(typeof(MkvTrackType), outputLine.Substring(outputLine.IndexOf(":") + 1, outputLine.IndexOf("(") - outputLine.IndexOf(":") - 1).Trim());
                    tmp.TrackID   = trackID;
                    if (outputLine.Contains("number"))
                    {
                        // if we have version 5.x and newer
                        tmp.TrackNumber = Int32.Parse(ExtractProperty(outputLine, "number"));
                    }
                    else
                    {
                        // if we have version 4.x and older
                        tmp.TrackNumber = tmp.TrackID;
                    }
                    if (outputLine.Contains("codec_id"))
                    {
                        // if we have version 5.x and newer
                        tmp.CodecID = ExtractProperty(outputLine, "codec_id");
                    }
                    else
                    {
                        // if we have version 4.x and older
                        tmp.CodecID = outputLine.Substring(outputLine.IndexOf("(") + 1, outputLine.IndexOf(")") - outputLine.IndexOf("(") - 1);
                    }

                    if (outputLine.Contains("language:"))
                    {
                        tmp.Language = ExtractProperty(outputLine, "language");
                    }
                    if (outputLine.Contains("track_name:"))
                    {
                        tmp.TrackName = ExtractProperty(outputLine, "track_name");
                    }
                    if (outputLine.Contains("codec_private_data:"))
                    {
                        tmp.CodecPrivateData = ExtractProperty(outputLine, "codec_private_data");
                    }
                    switch (tmp.TrackType)
                    {
                    case MkvTrackType.video:
                        if (outputLine.Contains("pixel_dimensions:"))
                        {
                            tmp.ExtraInfo = ExtractProperty(outputLine, "pixel_dimensions");
                        }
                        // in versions after v9.0.1, Mosu was kind enough to provide us with the minimum_timestamp property
                        // in order to determine the current track's delay
                        if (outputLine.Contains("minimum_timestamp:"))
                        {
                            Int64 tmpInt64;
                            if (Int64.TryParse(ExtractProperty(outputLine, "minimum_timestamp"), out tmpInt64))
                            {
                                tmp.MinimumTimestamp = tmpInt64;
                            }
                        }
                        break;

                    case MkvTrackType.audio:
                        if (outputLine.Contains("audio_sampling_frequency:"))
                        {
                            tmp.ExtraInfo = ExtractProperty(outputLine, "audio_sampling_frequency");
                        }
                        if (outputLine.Contains("audio_channels:"))
                        {
                            tmp.ExtraInfo += ", Ch:" + ExtractProperty(outputLine, "audio_channels");
                        }
                        // in versions after v9.0.1, Mosu was kind enough to provide us with the minimum_timestamp property
                        // in order to determine the current track's delay
                        if (outputLine.Contains("minimum_timestamp:"))
                        {
                            Int64 tmpInt64;
                            if (Int64.TryParse(ExtractProperty(outputLine, "minimum_timestamp"), out tmpInt64))
                            {
                                tmp.MinimumTimestamp = tmpInt64;
                            }
                        }
                        break;

                    case MkvTrackType.subtitles:
                        break;

                    default:
                        break;
                    }
                    _SegmentList.Add(tmp);
                }
                else if (outputLine.StartsWith("Attachment ID "))
                {
                    gMKVAttachment tmp = new gMKVAttachment();
                    tmp.ID       = Int32.Parse(outputLine.Substring(0, outputLine.IndexOf(":")).Replace("Attachment ID", String.Empty).Trim());
                    tmp.Filename = outputLine.Substring(outputLine.IndexOf("file name")).Replace("file name", string.Empty);
                    tmp.Filename = tmp.Filename.Substring(tmp.Filename.IndexOf("'") + 1, tmp.Filename.LastIndexOf("'") - 2).Trim();
                    tmp.FileSize = outputLine.Substring(outputLine.IndexOf("size")).Replace("size", string.Empty).Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries)[0].Replace("bytes", String.Empty).Trim();
                    tmp.MimeType = outputLine.Substring(outputLine.IndexOf("type")).Replace("type", string.Empty).Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries)[0].Replace("'", String.Empty).Trim();
                    _SegmentList.Add(tmp);
                }
                else if (outputLine.StartsWith("Chapters: "))
                {
                    gMKVChapter tmp = new gMKVChapter();
                    tmp.ChapterCount = Int32.Parse(outputLine.Replace("Chapters: ", string.Empty).Replace("entry", String.Empty).Replace("entries", string.Empty).Trim());
                    _SegmentList.Add(tmp);
                }
            }
        }
예제 #4
0
        public void FindCodecPrivate(List <gMKVSegment> argSegmentList)
        {
            foreach (gMKVSegment seg in argSegmentList)
            {
                if (seg is gMKVTrack)
                {
                    gMKVTrack track = (gMKVTrack)seg;
                    // Check if the track has CodecPrivateData
                    // and it doesn't have a text representation of CodecPrivate
                    if (!String.IsNullOrEmpty(track.CodecPrivateData) &&
                        String.IsNullOrEmpty(track.CodecPrivate))
                    {
                        byte[] codecPrivateBytes = HexStringToByteArray(track.CodecPrivateData);
                        if (track.TrackType == MkvTrackType.video)
                        {
                            if (track.CodecID == "V_MS/VFW/FOURCC")
                            {
                                track.CodecPrivate = String.Format("length {0} (FourCC: \"{1}\")"
                                                                   , codecPrivateBytes.Length
                                                                   , ((32 <= codecPrivateBytes[16]) && (127 > codecPrivateBytes[16]) ? System.Text.Encoding.ASCII.GetString(new byte[] { codecPrivateBytes[16] }) : "?") +
                                                                   ((32 <= codecPrivateBytes[17]) && (127 > codecPrivateBytes[17]) ? System.Text.Encoding.ASCII.GetString(new byte[] { codecPrivateBytes[17] }) : "?") +
                                                                   ((32 <= codecPrivateBytes[18]) && (127 > codecPrivateBytes[18]) ? System.Text.Encoding.ASCII.GetString(new byte[] { codecPrivateBytes[18] }) : "?") +
                                                                   ((32 <= codecPrivateBytes[19]) && (127 > codecPrivateBytes[19]) ? System.Text.Encoding.ASCII.GetString(new byte[] { codecPrivateBytes[19] }) : "?")
                                                                   );
                            }
                            else if (track.CodecID == "V_MPEG4/ISO/AVC")
                            {
                                Int32 profileIdc = codecPrivateBytes[1];
                                Int32 levelIdc   = codecPrivateBytes[3];

                                String profileIdcString = "";

                                switch (profileIdc)
                                {
                                case 44:
                                    profileIdcString = "CAVLC 4:4:4 Intra";
                                    break;

                                case 66:
                                    profileIdcString = "Baseline";
                                    break;

                                case 77:
                                    profileIdcString = "Main";
                                    break;

                                case 83:
                                    profileIdcString = "Scalable Baseline";
                                    break;

                                case 86:
                                    profileIdcString = "Scalable High";
                                    break;

                                case 88:
                                    profileIdcString = "Extended";
                                    break;

                                case 100:
                                    profileIdcString = "High";
                                    break;

                                case 110:
                                    profileIdcString = "High 10";
                                    break;

                                case 118:
                                    profileIdcString = "Multiview High";
                                    break;

                                case 122:
                                    profileIdcString = "High 4:2:2";
                                    break;

                                case 128:
                                    profileIdcString = "Stereo High";
                                    break;

                                case 144:
                                    profileIdcString = "High 4:4:4";
                                    break;

                                case 244:
                                    profileIdcString = "High 4:4:4 Predictive";
                                    break;

                                default:
                                    profileIdcString = "Unknown";
                                    break;
                                }

                                track.CodecPrivate = String.Format("length {0} (h.264 profile: {1} @L{2}.{3})"
                                                                   , codecPrivateBytes.Length
                                                                   , profileIdcString
                                                                   , levelIdc / 10
                                                                   , levelIdc % 10
                                                                   );
                            }
                            else if (track.CodecID == "V_MPEGH/ISO/HEVC")
                            {
                                BitArray codecPrivateBits = new BitArray(new byte[] { codecPrivateBytes[1] });

                                Int32 profileIdc = Convert.ToInt32((codecPrivateBits[4] ? "1" : "0") +
                                                                   (codecPrivateBits[3] ? "1" : "0") +
                                                                   (codecPrivateBits[2] ? "1" : "0") +
                                                                   (codecPrivateBits[1] ? "1" : "0") +
                                                                   (codecPrivateBits[0] ? "1" : "0"), 2);

                                Int32 levelIdc = codecPrivateBytes[12];

                                String profileIdcString = "";

                                switch (profileIdc)
                                {
                                case 1:
                                    profileIdcString = "Main";
                                    break;

                                case 2:
                                    profileIdcString = "Main 10";
                                    break;

                                case 3:
                                    profileIdcString = "Main Still Picture";
                                    break;

                                default:
                                    profileIdcString = "Unknown";
                                    break;
                                }

                                track.CodecPrivate = String.Format("length {0} (HEVC profile: {1} @L{2}.{3})"
                                                                   , codecPrivateBytes.Length
                                                                   , profileIdcString
                                                                   , levelIdc / 3 / 10
                                                                   , levelIdc / 3 % 10
                                                                   );
                            }
                            else
                            {
                                track.CodecPrivate = String.Format("length {0}", codecPrivateBytes.Length);
                            }
                        }
                        else if (track.TrackType == MkvTrackType.audio)
                        {
                            if (track.CodecID == "A_MS/ACM")
                            {
                                //UInt16 formatTag = BitConverter.ToUInt16(new byte[] { codecPrivateBytes[1], codecPrivateBytes[0] }, 0);
                                track.CodecPrivate = String.Format("length {0} (format tag: 0x{1:x2}{2:x2})"
                                                                   , codecPrivateBytes.Length
                                                                   , codecPrivateBytes[0]
                                                                   , codecPrivateBytes[1]
                                                                   );
                            }
                            else
                            {
                                track.CodecPrivate = String.Format("length {0}", codecPrivateBytes.Length);
                            }
                        }
                        else
                        {
                            track.CodecPrivate = String.Format("length {0}", codecPrivateBytes.Length);
                        }
                    }
                }
            }
        }
예제 #5
0
        public bool FindDelays(List <gMKVSegment> argSegmentList)
        {
            // Check to see if the list contains segments
            if (argSegmentList == null || argSegmentList.Count == 0)
            {
                return(false);
            }

            Int32 videoDelay = Int32.MinValue;

            // First, find the video delay
            foreach (gMKVSegment seg in argSegmentList)
            {
                if (seg is gMKVTrack)
                {
                    gMKVTrack track = (gMKVTrack)seg;
                    if (track.TrackType == MkvTrackType.video)
                    {
                        // Check if MinimumTimestamp property was found
                        if (track.MinimumTimestamp == Int64.MinValue)
                        {
                            // Could not determine the delays
                            return(false);
                        }
                        // Convert to ms from ns
                        videoDelay           = Convert.ToInt32(track.MinimumTimestamp / 1000000);
                        track.Delay          = videoDelay;
                        track.EffectiveDelay = videoDelay;
                        break;
                    }
                }
            }

            // Check if video delay was found
            if (videoDelay == Int32.MinValue)
            {
                // Could not determine the delays
                return(false);
            }

            // If video delay was found, then determine the audio track delay
            foreach (gMKVSegment seg in argSegmentList)
            {
                if (seg is gMKVTrack)
                {
                    gMKVTrack track = (gMKVTrack)seg;
                    if (track.TrackType == MkvTrackType.audio)
                    {
                        // Check if MinimumTimestamp property was found
                        if (track.MinimumTimestamp == Int64.MinValue)
                        {
                            // Could not determine the delays
                            return(false);
                        }
                        // Convert to ms from ns
                        track.Delay          = Convert.ToInt32(track.MinimumTimestamp / 1000000);
                        track.EffectiveDelay = track.Delay - videoDelay;
                    }
                }
            }

            // If everything went all right, then we return true
            return(true);
        }
예제 #6
0
        private void ParseMkvInfoOutput()
        {
            // start the loop for each line of the output
            gMKVSegment       tmpSegment   = null;
            MkvInfoParseState tmpState     = MkvInfoParseState.Searching;
            Int32             attachmentID = 1;

            foreach (String outputLine in _MKVInfoOutput.ToString().Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                // first determine the parse state we are in
                //if (outputLine.Contains("Segment,"))
                //{
                //    tmpState = MkvInfoParseState.InsideSegmentInfo;
                //    continue;
                //}
                if (outputLine.Contains("Segment information"))
                {
                    // if previous segment is not null, add it to the list and create a new one
                    if (tmpSegment != null)
                    {
                        _SegmentList.Add(tmpSegment);
                    }
                    tmpSegment = new gMKVSegmentInfo();
                    tmpState   = MkvInfoParseState.InsideSegmentInfo;
                    continue;
                }
                else if (outputLine.Contains("Segment tracks"))
                {
                    tmpState = MkvInfoParseState.InsideTrackInfo;
                    continue;
                }
                else if (outputLine.Contains("Attachments"))
                {
                    tmpState = MkvInfoParseState.InsideAttachentInfo;
                    continue;
                }
                else if (outputLine.Contains("Chapters"))
                {
                    tmpState = MkvInfoParseState.InsideChapterInfo;
                    continue;
                }

                // now that we have determined the state, we parse the segment
                switch (tmpState)
                {
                case MkvInfoParseState.Searching:
                    // if we are still searching for the state, just continue with next line
                    continue;

                case MkvInfoParseState.InsideSegmentInfo:
                    //if (outputLine.Contains("Segment information"))
                    //{
                    //    // if previous segment is not null, add it to the list and create a new one
                    //    if (tmpSegment != null)
                    //    {
                    //        _SegmentList.Add(tmpSegment);
                    //    }
                    //    tmpSegment = new gMKVSegmentInfo();
                    //}
                    //else if (outputLine.Contains("Timecode scale:"))
                    if (outputLine.Contains("Timecode scale:"))
                    {
                        ((gMKVSegmentInfo)tmpSegment).TimecodeScale = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Muxing application:"))
                    {
                        ((gMKVSegmentInfo)tmpSegment).MuxingApplication = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Writing application:"))
                    {
                        ((gMKVSegmentInfo)tmpSegment).WritingApplication = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Duration:"))
                    {
                        ((gMKVSegmentInfo)tmpSegment).Duration = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Date:"))
                    {
                        ((gMKVSegmentInfo)tmpSegment).Date = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    //8 + Segment, size 320677930
                    //9 |+ Seek head (subentries will be skipped)
                    //10 |+ EbmlVoid (size: 4013)
                    //11 |+ Segment information
                    //12 | + Timecode scale: 1000000
                    //13 | + Muxing application: libebml v1.3.0 + libmatroska v1.4.1
                    //14 | + Writing application: mkvmerge v6.6.0 ('The Edge Of The In Between') built on Dec  1 2013 17:55:00
                    //15 | + Duration: 1364.905s (00:22:44.905)
                    //16 | + Date: Mon Jan 20 21:40:32 2014 UTC
                    //17 | + Segment UID: 0xa3 0x55 0x8d 0x9c 0x25 0x0f 0xba 0x16 0x94 0x09 0xf0 0xc9 0xb4 0x0f 0xc7 0x4b
                    break;

                case MkvInfoParseState.InsideTrackInfo:
                    if (outputLine.Contains("+ A track"))
                    {
                        // if previous segment is not null, add it to the list and create a new one
                        if (tmpSegment != null)
                        {
                            _SegmentList.Add(tmpSegment);
                        }
                        tmpSegment = new gMKVTrack();
                    }
                    else if (outputLine.Contains("Track number:"))
                    {
                        if (outputLine.Contains("track ID for mkvmerge & mkvextract"))
                        {
                            // if we have version 5.x and newer
                            ((gMKVTrack)tmpSegment).TrackNumber = Int32.Parse(outputLine.Substring(outputLine.IndexOf(":") + 1, outputLine.IndexOf("(") - outputLine.IndexOf(":") - 1).Trim());
                            ((gMKVTrack)tmpSegment).TrackID     = Int32.Parse(outputLine.Substring(outputLine.LastIndexOf(":") + 1, outputLine.IndexOf(")") - outputLine.LastIndexOf(":") - 1).Trim());
                        }
                        else
                        {
                            // if we have version 4.x and older
                            ((gMKVTrack)tmpSegment).TrackNumber = Int32.Parse(outputLine.Substring(outputLine.IndexOf(":") + 1).Trim());
                            ((gMKVTrack)tmpSegment).TrackID     = ((gMKVTrack)tmpSegment).TrackNumber;
                        }
                    }
                    else if (outputLine.Contains("Track type:"))
                    {
                        ((gMKVTrack)tmpSegment).TrackType = (MkvTrackType)Enum.Parse(typeof(MkvTrackType), outputLine.Substring(outputLine.IndexOf(":") + 1).Trim());
                    }
                    else if (outputLine.Contains("Codec ID:"))
                    {
                        ((gMKVTrack)tmpSegment).CodecID = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Language:"))
                    {
                        ((gMKVTrack)tmpSegment).Language = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Name:"))
                    {
                        ((gMKVTrack)tmpSegment).TrackName = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Pixel width:"))
                    {
                        ((gMKVTrack)tmpSegment).ExtraInfo = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Pixel height:"))
                    {
                        ((gMKVTrack)tmpSegment).ExtraInfo += "x" + outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Sampling frequency:"))
                    {
                        ((gMKVTrack)tmpSegment).ExtraInfo = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Channels:"))
                    {
                        ((gMKVTrack)tmpSegment).ExtraInfo += ", Ch:" + outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("CodecPrivate,"))
                    {
                        ((gMKVTrack)tmpSegment).CodecPrivate = outputLine.Substring(outputLine.IndexOf(",") + 1).Trim();
                    }

                    //18 |+ Segment tracks
                    //19 | + A track
                    //20 |  + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
                    //21 |  + Track UID: 16103463283017343410
                    //22 |  + Track type: video
                    //23 |  + Lacing flag: 0
                    //24 |  + MinCache: 1
                    //25 |  + Codec ID: V_MPEG4/ISO/AVC
                    //26 |  + CodecPrivate, length 41 (h.264 profile: High @L4.1)
                    //27 |  + Default duration: 41.708ms (23.976 frames/fields per second for a video track)
                    //28 |  + Language: jpn
                    //29 |  + Name: Video
                    //30 |  + Video track
                    //31 |   + Pixel width: 1280
                    //32 |   + Pixel height: 720
                    //33 |   + Display width: 1280
                    //34 |   + Display height: 720
                    //35 | + A track
                    //36 |  + Track number: 2 (track ID for mkvmerge & mkvextract: 1)
                    //37 |  + Track UID: 7691413846401821864
                    //38 |  + Track type: audio
                    //39 |  + Codec ID: A_AAC
                    //40 |  + CodecPrivate, length 5
                    //41 |  + Default duration: 21.333ms (46.875 frames/fields per second for a video track)
                    //42 |  + Language: jpn
                    //43 |  + Name: Audio
                    //44 |  + Audio track
                    //45 |   + Sampling frequency: 48000
                    //46 |   + Channels: 2
                    //47 | + A track
                    //48 |  + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
                    //49 |  + Track UID: 12438050378713133751
                    //50 |  + Track type: subtitles
                    //51 |  + Lacing flag: 0
                    //52 |  + Codec ID: S_TEXT/ASS
                    //53 |  + CodecPrivate, length 1530
                    //54 |  + Language: gre
                    //55 |  + Name: Subs
                    break;

                case MkvInfoParseState.InsideAttachentInfo:
                    if (outputLine.Contains("Attached"))
                    {
                        // if previous segment is not null, add it to the list and create a new one
                        if (tmpSegment != null)
                        {
                            _SegmentList.Add(tmpSegment);
                        }
                        tmpSegment = new gMKVAttachment();
                        ((gMKVAttachment)tmpSegment).ID = attachmentID;
                        attachmentID++;
                    }
                    else if (outputLine.Contains("File name:"))
                    {
                        ((gMKVAttachment)tmpSegment).Filename = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("File data, size:"))
                    {
                        ((gMKVAttachment)tmpSegment).FileSize = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }
                    else if (outputLine.Contains("Mime type:"))
                    {
                        ((gMKVAttachment)tmpSegment).MimeType = outputLine.Substring(outputLine.IndexOf(":") + 1).Trim();
                    }

                    //57 |+ Attachments
                    //58 | + Attached
                    //59 |  + File name: CENSCBK.TTF
                    //60 |  + Mime type: application/x-truetype-font
                    //61 |  + File data, size: 51716
                    //62 |  + File UID: 2140725150727954330
                    //63 | + Attached
                    //64 |  + File name: segoeui.ttf
                    //65 |  + Mime type: application/x-truetype-font
                    //66 |  + File data, size: 516560
                    //67 |  + File UID: 16764867774861384581
                    //68 | + Attached
                    //69 |  + File name: segoeuib.ttf
                    //70 |  + Mime type: application/x-truetype-font
                    //71 |  + File data, size: 497372
                    //72 |  + File UID: 9565689537892410299
                    //73 | + Attached
                    //74 |  + File name: segoeuii.ttf
                    //75 |  + Mime type: application/x-truetype-font
                    //76 |  + File data, size: 385560
                    //77 |  + File UID: 13103126947871579286
                    //78 | + Attached
                    //79 |  + File name: segoeuil.ttf
                    //80 |  + Mime type: application/x-truetype-font
                    //81 |  + File data, size: 330908
                    //82 |  + File UID: 3235680178630447031
                    //83 | + Attached
                    //84 |  + File name: segoeuiz.ttf
                    //85 |  + Mime type: application/x-truetype-font
                    //86 |  + File data, size: 398148
                    //87 |  + File UID: 17520358819351445890
                    //88 | + Attached
                    //89 |  + File name: seguisb.ttf
                    //90 |  + Mime type: application/x-truetype-font
                    //91 |  + File data, size: 406192
                    //92 |  + File UID: 8550836732450669472

                    break;

                case MkvInfoParseState.InsideChapterInfo:
                    if (outputLine.Contains("EditionEntry"))
                    {
                        // if previous segment is not null, add it to the list and create a new one
                        if (tmpSegment != null)
                        {
                            _SegmentList.Add(tmpSegment);
                        }
                        tmpSegment = new gMKVChapter();
                    }
                    else if (outputLine.Contains("ChapterAtom"))
                    {
                        ((gMKVChapter)tmpSegment).ChapterCount += 1;
                    }

                    //93 |+ Chapters
                    //94 | + EditionEntry
                    //95 |  + EditionFlagHidden: 0
                    //96 |  + EditionFlagDefault: 0
                    //97 |  + EditionUID: 5248481698181523363
                    //98 |  + ChapterAtom
                    //99 |   + ChapterUID: 13651813039521317265
                    //100 |   + ChapterTimeStart: 00:00:00.000000000
                    //101 |   + ChapterTimeEnd: 00:00:40.874000000
                    //102 |   + ChapterFlagHidden: 0
                    //103 |   + ChapterFlagEnabled: 1
                    //104 |   + ChapterDisplay
                    //105 |    + ChapterString: ��������
                    //106 |    + ChapterLanguage: und
                    //107 |  + ChapterAtom
                    //108 |   + ChapterUID: 9861180919652459706
                    //109 |   + ChapterTimeStart: 00:00:40.999000000
                    //110 |   + ChapterTimeEnd: 00:02:00.829000000
                    //111 |   + ChapterFlagHidden: 0
                    //112 |   + ChapterFlagEnabled: 1
                    //113 |   + ChapterDisplay
                    //114 |    + ChapterString: ������ �����
                    //115 |    + ChapterLanguage: und
                    //116 |  + ChapterAtom
                    //117 |   + ChapterUID: 18185444543032186557
                    //118 |   + ChapterTimeStart: 00:02:00.954000000
                    //119 |   + ChapterTimeEnd: 00:21:24.700000000
                    //120 |   + ChapterFlagHidden: 0
                    //121 |   + ChapterFlagEnabled: 1
                    //122 |   + ChapterDisplay
                    //123 |    + ChapterString: ������ �����
                    //124 |    + ChapterLanguage: und
                    //125 |  + ChapterAtom
                    //126 |   + ChapterUID: 12481834811641996944
                    //127 |   + ChapterTimeStart: 00:21:24.867000000
                    //128 |   + ChapterTimeEnd: 00:22:44.864000000
                    //129 |   + ChapterFlagHidden: 0
                    //130 |   + ChapterFlagEnabled: 1
                    //131 |   + ChapterDisplay
                    //132 |    + ChapterString: ������ ������
                    //133 |    + ChapterLanguage: und

                    break;

                default:
                    break;
                }
            }
            // if the last segment was not added to the list and it is not null, add it to the list
            if (tmpSegment != null)
            {
                _SegmentList.Add(tmpSegment);
            }
        }
예제 #7
0
        private String getAudioFileExtensionFromCodecID(gMKVTrack argTrack)
        {
            String outputFileExtension = String.Empty;

            if (argTrack.CodecID.ToUpper().Contains("A_MPEG/L3"))
            {
                outputFileExtension = "mp3";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_MPEG/L2"))
            {
                outputFileExtension = "mp2";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_MPEG/L1"))
            {
                outputFileExtension = "mpa";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_PCM"))
            {
                outputFileExtension = "wav";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_MPC"))
            {
                outputFileExtension = "mpc";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_AC3"))
            {
                outputFileExtension = "ac3";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_ALAC"))
            {
                outputFileExtension = "caf";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_DTS"))
            {
                outputFileExtension = "dts";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_VORBIS"))
            {
                outputFileExtension = "ogg";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_FLAC"))
            {
                outputFileExtension = "flac";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_REAL"))
            {
                outputFileExtension = "ra";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_MS/ACM"))
            {
                outputFileExtension = "wav";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_AAC"))
            {
                outputFileExtension = "aac";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_QUICKTIME"))
            {
                outputFileExtension = "mov";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_TRUEHD"))
            {
                outputFileExtension = "thd";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_TTA1"))
            {
                outputFileExtension = "tta";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_WAVPACK4"))
            {
                outputFileExtension = "wv";
            }
            else if (argTrack.CodecID.ToUpper().Contains("A_OPUS"))
            {
                outputFileExtension = "opus";
            }
            else
            {
                outputFileExtension = "mka";
            }
            return(outputFileExtension);
        }