private void input_SelectionChanged(object sender, string val)
        {
            // get language
            bool bFound = false;

            foreach (KeyValuePair <string, string> strLanguage in LanguageSelectionContainer.Languages)
            {
                if (input.SelectedText.ToLower(System.Globalization.CultureInfo.InvariantCulture).Contains(strLanguage.Key.ToLower(System.Globalization.CultureInfo.InvariantCulture)))
                {
                    SetLanguage(strLanguage.Key);
                    bFound = true;
                    break;
                }
            }
            if (!bFound && input.SelectedText.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".idx"))
            {
                List <SubtitleInfo> subTracks;
                idxReader.readFileProperties(input.SelectedText, out subTracks);
                if (subTracks.Count > 0)
                {
                    SetLanguage(LanguageSelectionContainer.Short2FullLanguageName(subTracks[0].Name));
                    bFound = true;
                }
            }
            if (!bFound && this.SelectedItem != null && this.SelectedStreamIndex > 0)
            {
                SetLanguage(defaultLanguage);
            }

            // get delay & track name
            delay.Value = 0;
            if (this.SelectedItem != null && this.SelectedStreamIndex > 0 && this.SelectedItem.Tag is OneClickStream)
            {
                delay.Value  = ((OneClickStream)this.SelectedItem.Tag).Delay;
                subName.Text = ((OneClickStream)this.SelectedItem.Tag).Name;
            }
            if (PrettyFormatting.getDelayAndCheck(input.SelectedText) != null)
            {
                delay.Value = PrettyFormatting.getDelayAndCheck(input.SelectedText) ?? 0;
            }

            if (showDefaultStream)
            {
                chkDefaultStream.Checked = this.SelectedStream.DefaultStream;
            }

            if (showForceStream)
            {
                chkForceStream.Checked = this.SelectedStream.ForcedStream;
            }

            raiseEvent();
        }
示例#2
0
        private void input_SelectionChanged(object sender, string val)
        {
            // get language
            bool   bFound      = false;
            string strLanguage = LanguageSelectionContainer.GetLanguageFromFileName(System.IO.Path.GetFileNameWithoutExtension(input.SelectedText));

            if (!String.IsNullOrEmpty(strLanguage))
            {
                SetLanguage(strLanguage);
                bFound = true;
            }
            else if (input.SelectedText.ToLowerInvariant().EndsWith(".idx"))
            {
                List <SubtitleInfo> subTracks;
                idxReader.readFileProperties(input.SelectedText, out subTracks);
                if (subTracks.Count > 0)
                {
                    SetLanguage(LanguageSelectionContainer.LookupISOCode(subTracks[0].Name));
                    bFound = true;
                }
            }
            if (!bFound && this.SelectedItem != null && this.SelectedStreamIndex > 0)
            {
                SetLanguage(MainForm.Instance.Settings.DefaultLanguage1);
            }

            // get delay & track name
            delay.Value = 0;
            if (this.SelectedItem != null && this.SelectedStreamIndex > 0 && this.SelectedItem.Tag is OneClickStream)
            {
                delay.Value  = ((OneClickStream)this.SelectedItem.Tag).Delay;
                subName.Text = ((OneClickStream)this.SelectedItem.Tag).Name;
            }
            if (PrettyFormatting.getDelayAndCheck(input.SelectedText) != null)
            {
                delay.Value = PrettyFormatting.getDelayAndCheck(input.SelectedText) ?? 0;
            }

            if (showDefaultStream)
            {
                chkDefaultStream.Checked = this.SelectedStream.DefaultStream;
            }

            if (showForceStream)
            {
                chkForceStream.Checked = this.SelectedStream.ForcedStream;
            }

            raiseEvent();
        }
示例#3
0
        /// <summary>
        /// handles the go button for automated encoding
        /// checks if we're in automated 2 pass video mode
        /// then the video and audio configuration is checked, and if it checks out
        /// the audio job, video jobs and muxing job are generated, audio and video job are linked
        /// and encoding is started
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void queueButton_Click(object sender, System.EventArgs e)
        {
            if (String.IsNullOrEmpty(this.muxedOutput.Filename))
            {
                return;
            }

            FileSize?desiredSize = targetSize.Value;
            FileSize?splitSize   = splitting.Value;
            LogItem  log         = new LogItem(this.muxedOutput.Filename);

            MainForm.Instance.AutoEncodeLog.Add(log);

            if (FileSizeRadio.Checked)
            {
                log.LogValue("Desired Size", desiredSize);
            }
            else if (averageBitrateRadio.Checked)
            {
                log.LogValue("Projected Bitrate", string.Format("{0}kbps", projectedBitrateKBits.Text));
            }
            else
            {
                log.LogEvent("No Target Size (use profile settings)");
            }

            log.LogValue("Split Size", splitSize);

            MuxStream[]        audio;
            AudioJob[]         aStreams;
            AudioEncoderType[] muxTypes;
            separateEncodableAndMuxableAudioStreams(out aStreams, out audio, out muxTypes);
            MuxStream[]   subtitles   = new MuxStream[0];
            ChapterInfo   chapters    = new ChapterInfo();
            string        videoInput  = vInfo.VideoInput;
            string        videoOutput = vInfo.VideoOutput;
            string        muxedOutput = this.muxedOutput.Filename;
            ContainerType cot         = this.container.SelectedItem as ContainerType;

            // determine audio language
            foreach (MuxStream stream in audio)
            {
                string strLanguage = LanguageSelectionContainer.GetLanguageFromFileName(Path.GetFileNameWithoutExtension(stream.path));
                if (!String.IsNullOrEmpty(strLanguage))
                {
                    stream.language = strLanguage;
                }
            }

            if (addSubsNChapters.Checked)
            {
                AdaptiveMuxWindow amw = new AdaptiveMuxWindow();
                amw.setMinimizedMode(videoOutput, "", videoStream.Settings.EncoderType, JobUtil.getFramerate(videoInput), audio,
                                     muxTypes, muxedOutput, splitSize, cot);
                if (amw.ShowDialog() == DialogResult.OK)
                {
                    amw.getAdditionalStreams(out audio, out subtitles, out chapters, out muxedOutput, out cot);
                }
                else // user aborted, abort the whole process
                {
                    return;
                }
            }
            removeStreamsToBeEncoded(ref audio, aStreams);
            MainForm.Instance.Jobs.AddJobsWithDependencies(VideoUtil.GenerateJobSeries(videoStream, muxedOutput, aStreams, subtitles, new List <string>(), String.Empty, chapters,
                                                                                       desiredSize, splitSize, cot, prerender, audio, log, device.Text, vInfo.Zones, null, null, false), true);
            this.Close();
        }
示例#4
0
        /// <summary>
        /// extracts the subtitle tracks in multiple files if needed
        /// </summary>
        private void writeSubtitles()
        {
            string strInputFile = job.Output;

            if (!base.bFirstPass)
            {
                strInputFile = Path.Combine(Path.GetDirectoryName(strInputFile), Path.GetFileNameWithoutExtension(strInputFile) + "_forced.idx");
                string   strSUBFile = Path.ChangeExtension(strInputFile, ".sub");
                FileInfo f          = null;
                if (File.Exists(strSUBFile))
                {
                    f = new FileInfo(strSUBFile);
                }
                if (f == null || f.Length == 0)
                {
                    log.LogEvent("no forced subtitles found");
                    job.FilesToDelete.Add(strInputFile);
                    job.FilesToDelete.Add(strSUBFile);
                    return;
                }
            }

            if (job.SingleFileExport || !File.Exists(strInputFile))
            {
                return;
            }

            // multiple output files have to be generated based on the single input file
            su.Status = "Generating files...";

            string        line;
            string        strLanguage   = string.Empty;
            bool          bHeader       = true; // same header for all output files
            bool          bWait         = false;
            bool          bContentFound = false;
            StringBuilder sbHeader      = new StringBuilder();
            StringBuilder sbIndex       = new StringBuilder();
            StringBuilder sbIndexTemp   = new StringBuilder();
            int           index         = 0;

            using (StreamReader file = new StreamReader(strInputFile))
            {
                while ((line = file.ReadLine()) != null)
                {
                    if (bHeader)
                    {
                        if (line.StartsWith("langidx:"))
                        {
                            // first subtitle track detected
                            bHeader = false;
                            bWait   = true;
                        }
                        else
                        {
                            sbHeader.AppendLine(line);
                        }
                    }
                    else if (bWait)
                    {
                        sbIndexTemp.AppendLine(line);
                        if (line.StartsWith("id: "))
                        {
                            // new track detected
                            index       = Int32.Parse(line.Substring(line.LastIndexOf(' ')));
                            strLanguage = line.Substring(line.IndexOf(' ') + 1, line.LastIndexOf(',') - line.IndexOf(' ') - 1);
                            strLanguage = LanguageSelectionContainer.LookupISOCode(strLanguage);

                            // create full output text
                            sbIndex.Clear();
                            sbIndex.Append(sbHeader.ToString());
                            sbIndex.AppendLine("langidx: " + index);
                            sbIndex.Append(sbIndexTemp.ToString());
                            bWait         = false;
                            bContentFound = false;
                        }
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(line))
                        {
                            bWait = true;

                            // check if the track found in the input file is selected to be demuxed
                            bool bFound = false;
                            if (!job.IndexAllTracks)
                            {
                                foreach (int id in job.TrackIDs)
                                {
                                    if (index == id)
                                    {
                                        bFound = true;
                                    }
                                }
                            }

                            // export if found or if all tracks should be demuxed
                            if ((bFound && bFirstPass) || (bFound && !bFirstPass && bContentFound) || (job.IndexAllTracks && bContentFound))
                            {
                                // create output file
                                string outputFile = Path.Combine(Path.GetDirectoryName(job.Output),
                                                                 Path.GetFileNameWithoutExtension(job.Output)) + "_" + index + "_" + strLanguage + (!base.bFirstPass ? "_forced" : string.Empty) + ".idx";
                                using (StreamWriter output = new StreamWriter(outputFile))
                                    output.WriteLine(sbIndex.ToString());

                                outputFile = Path.ChangeExtension(outputFile, ".sub");
                                File.Copy(Path.ChangeExtension(strInputFile, ".sub"), outputFile, true);

                                log.LogEvent("Subtitle file created: " + Path.GetFileName(outputFile));
                            }

                            sbIndexTemp.Clear();
                            sbIndexTemp.AppendLine(line);
                        }
                        else
                        {
                            if (line.StartsWith("timestamp:"))
                            {
                                bContentFound = true;
                            }
                            sbIndex.AppendLine(line);
                        }
                    }
                }
            }
        }