Beispiel #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);
                }
            }
        }
        /// <summary>
        /// Update the information related to Subs1 or Subs2.
        /// </summary>
        private void updateSubs(int subsNum)
        {
            TextBox textbox;
            string  file;

            // Get items that depend on whether it's subs1 or subs2
            if (subsNum == 1)
            {
                textbox = this.textBoxSubs1File;
                file    = this.textBoxSubs1File.Text.Trim();
            }
            else
            {
                textbox = this.textBoxSubs2File;
                file    = this.textBoxSubs2File.Text.Trim();
            }

            // If input file is an MKV, show the MKV track select dialog
            if (Path.GetExtension(file) == ".mkv")
            {
                List <MkvTrack> allSubTrackList = UtilsMkv.getSubtitleTrackList(file);
                List <MkvTrack> subTrackList    = new List <MkvTrack>();

                // Remove VOBSUB tracks
                foreach (MkvTrack subTrack in allSubTrackList)
                {
                    if (subTrack.Extension != "sub")
                    {
                        subTrackList.Add(subTrack);
                    }
                }

                if (subTrackList.Count == 0)
                {
                    UtilsMsg.showInfoMsg("This .mkv file does not contain any subtitle tracks.");
                    textbox.Text = "";
                }
                else
                {
                    DialogSelectMkvTrack mkvDlg = new DialogSelectMkvTrack(file, subsNum, subTrackList);
                    DialogResult         result = mkvDlg.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        textbox.Text = mkvDlg.ExtractedFile;
                    }
                    else
                    {
                        textbox.Text = "";
                    }
                }

                return; // Since textbox.Text was changed, this routine will be called again
            }
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        private void backgroundWorkerMain_DoWork(object sender, DoWorkEventArgs e)
        {
            string tempFileName = ConstantSettings.TempMkvExtractSubs1Filename;

            if (subsNum == 2)
            {
                tempFileName = ConstantSettings.TempMkvExtractSubs2Filename;
            }

            ExtractedFile = $"{Path.GetTempPath()}{tempFileName}.{selectedTrack.Extension}";

            UtilsMkv.extractTrack(mvkFile, selectedTrack.TrackID, ExtractedFile);

            // The subs1 and subs2 textboxes, take .idx files rather than .sub files
            if (Path.GetExtension(ExtractedFile) == ".sub")
            {
                ExtractedFile = Path.ChangeExtension(ExtractedFile, ".idx");
            }
        }
        private void backgroundWorkerMain_DoWork(object sender, DoWorkEventArgs e)
        {
            string tempFileName = ConstantSettings.TempMkvExtractSubs1Filename;

            if (subsNum == 2)
            {
                tempFileName = ConstantSettings.TempMkvExtractSubs2Filename;
            }

            this.ExtractedFile = String.Format("{0}{1}.{2}",
                                               Path.GetTempPath(), tempFileName, this.selectedTrack.Extension);

            UtilsMkv.extractTrack(this.mvkFile, this.selectedTrack.TrackID, this.ExtractedFile);

            // The subs1 and subs2 textboxes, take .idx files rather than .sub files
            if (Path.GetExtension(this.ExtractedFile) == ".sub")
            {
                this.ExtractedFile = Path.ChangeExtension(this.ExtractedFile, ".idx");
            }
        }