Пример #1
0
        /// <summary>
        /// Select the default subtitle track.
        /// </summary>
        /// <param name="subtitle">
        /// The subtitle.
        /// </param>
        public void SelectDefaultTrack(SubtitleTrack subtitle)
        {
            foreach (SubtitleTrack track in this.Task.SubtitleTracks)
            {
                if (track == subtitle)
                {
                    continue; // Skip the track the user selected.
                }

                track.Default = false;
            }

            this.NotifyOfPropertyChange(() => this.Task);
        }
Пример #2
0
        /// <summary>
        /// Select the burned in track.
        /// </summary>
        /// <param name="subtitle">
        /// The subtitle.
        /// </param>
        public void SetBurnedToFalseForAllExcept(SubtitleTrack subtitle)
        {
            foreach (SubtitleTrack track in this.Task.SubtitleTracks)
            {
                if (track == subtitle)
                {
                    continue; // Skip the track the user selected.
                }

                track.Burned = false;
            }

            this.NotifyOfPropertyChange(() => this.Task);
        }
Пример #3
0
        private void AddInputSubtitles(string[] filenames)
        {
            foreach (var srtFile in filenames)
            {
                if (!File.Exists(srtFile))
                {
                    continue;
                }

                SubtitleTrack track = new SubtitleTrack
                {
                    SrtFileName  = Path.GetFileNameWithoutExtension(srtFile),
                    SrtOffset    = 0,
                    SrtCharCode  = "UTF-8",
                    SrtLang      = "English",
                    SubtitleType = SubtitleType.IMPORTSRT,
                    SrtPath      = srtFile
                };
                this.Task.SubtitleTracks.Add(track);
            }
        }
Пример #4
0
        /// <summary>
        /// Add a subtitle track.
        /// The Source track is set based on the following order. If null, it will skip to the next option.
        ///   1. Passed in Subtitle param
        ///   2. First preferred Subtitle from source
        ///   3. First subtitle from source.
        /// Will not add a subtitle if the source has none.
        /// </summary>
        /// <param name="subtitle">
        /// The subtitle. Use null to add preferred, or first from source (based on user preference)
        /// </param>
        private void Add(Subtitle subtitle)
        {
            Subtitle source = subtitle
                              ?? ((this.SourceTracks != null)
                                      ? (this.SourceTracks.FirstOrDefault(l => l.Language == this.GetPreferredSubtitleTrackLanguage())
                                         ?? this.SourceTracks.FirstOrDefault(
                                             s => !s.IsFakeForeignAudioScanTrack))
                                      : null);

            if (source == null)
            {
                source = foreignAudioSearchTrack;

                if (this.Task.SubtitleTracks.Any(s => s.SourceTrack.Equals(this.foreignAudioSearchTrack)))
                {
                    return; // Don't add more than one Foreign Audio Scan
                }
            }


            SubtitleTrack track = new SubtitleTrack
            {
                SubtitleType = source.SubtitleType,
                SourceTrack  = source,
            };

            // Burn-in Behaviours
            if (this.SubtitleBehaviours.SelectedBurnInBehaviour == SubtitleBurnInBehaviourModes.ForeignAudio ||
                this.SubtitleBehaviours.SelectedBurnInBehaviour == SubtitleBurnInBehaviourModes.ForeignAudioPreferred)
            {
                if (subtitle != null && subtitle.IsFakeForeignAudioScanTrack)
                {
                    // Only set burned if it's an an available option.
                    if (this.Task.OutputFormat == OutputFormat.Mp4 && this.Task.SubtitleTracks.Any(s => s.Burned))
                    {
                        track.Burned = false;
                    }
                    else
                    {
                        track.Burned = true;
                        this.SetBurnedToFalseForAllExcept(track);
                    }
                }
            }

            // For MP4, PGS Subtitles must be burned in.
            if (!track.Burned && (source.SubtitleType == SubtitleType.PGS) && this.Task != null && this.Task.OutputFormat == OutputFormat.Mp4)
            {
                if (this.Task.SubtitleTracks.Any(a => a.Burned))
                {
                    return; // We can't add any more burned in tracks.
                }

                if (track.CanBeBurned)
                {
                    track.Burned = true;
                    this.SetBurnedToFalseForAllExcept(track);
                }
            }

            var encodeTask = this.Task;

            if (encodeTask != null)
            {
                encodeTask.SubtitleTracks.Add(track);
            }
        }
Пример #5
0
 /// <summary>
 /// Remove a Track
 /// </summary>
 /// <param name="track">
 /// The track.
 /// </param>
 public void Remove(SubtitleTrack track)
 {
     this.Task.SubtitleTracks.Remove(track);
 }