Exemplo n.º 1
0
        private void backgroundWorkerMain_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            MkvExtractProgress progress = new MkvExtractProgress();

            progress.MaxEpisode = selectedMkvFiles.Count;

            foreach (string file in selectedMkvFiles)
            {
                progress.CurEpisode++;

                List <MkvTrack> tracks = null;

                if (trackTypeToExtract == "All subtitle tracks")
                {
                    tracks = UtilsMkv.getSubtitleTrackList(file);
                }
                else if (trackTypeToExtract == "All audio tracks")
                {
                    tracks = UtilsMkv.getAudioTrackList(file);
                }
                else
                {
                    tracks = UtilsMkv.getTrackList(file);
                }

                progress.CurTrack = 0;
                progress.MaxTrack = tracks.Count;

                foreach (MkvTrack track in tracks)
                {
                    if (worker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }

                    progress.CurTrack++;

                    worker.ReportProgress(0, progress);

                    string displayLang = UtilsLang.LangThreeLetter2Full(track.Lang);

                    if (displayLang == "")
                    {
                        displayLang = "Unknown";
                    }

                    string fileName =
                        $"{outDir}{Path.DirectorySeparatorChar}{Path.GetFileNameWithoutExtension(file)} - Track {Convert.ToInt32(track.TrackID):00} - {displayLang}.{track.Extension}";

                    UtilsMkv.extractTrack(file, track.TrackID, fileName);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get list of audio tracks in the provided .mkv file.
        /// </summary>
        public static List <MkvTrack> getAudioTrackList(string mkvFile)
        {
            List <MkvTrack> audioTrackList = new List <MkvTrack>();
            List <MkvTrack> allTrackList   = UtilsMkv.getTrackList(mkvFile);

            foreach (MkvTrack track in allTrackList)
            {
                if (track.TrackType == TrackType.AUDIO)
                {
                    audioTrackList.Add(track);
                }
            }

            return(audioTrackList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get list of subtitle tracks in the provided .mkv file.
        /// </summary>
        public static List <MkvTrack> getSubtitleTrackList(string mkvFile)
        {
            List <MkvTrack> subtitleTrackList = new List <MkvTrack>();
            List <MkvTrack> allTrackList      = UtilsMkv.getTrackList(mkvFile);

            foreach (MkvTrack track in allTrackList)
            {
                if (track.TrackType == TrackType.SUBTITLES)
                {
                    subtitleTrackList.Add(track);
                }
            }

            return(subtitleTrackList);
        }