Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SubtitleTrack"/> class.
 /// Copy Constructor
 /// </summary>
 /// <param name="subtitle">
 /// The subtitle.
 /// </param>
 public SubtitleTrack(SubtitleTrack subtitle)
 {
     this.Burned       = subtitle.Burned;
     this.Default      = subtitle.Default;
     this.Forced       = subtitle.Forced;
     this.sourceTrack  = subtitle.SourceTrack;
     this.SrtCharCode  = subtitle.SrtCharCode;
     this.SrtFileName  = subtitle.SrtFileName;
     this.SrtLang      = subtitle.SrtLang;
     this.SrtOffset    = subtitle.SrtOffset;
     this.SrtPath      = subtitle.SrtPath;
     this.SubtitleType = subtitle.SubtitleType;
     this.SourceTrack  = subtitle.SourceTrack;
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SubtitleTrack"/> class.
 /// Copy Constructor
 /// </summary>
 /// <param name="subtitle">
 /// The subtitle.
 /// </param>
 public SubtitleTrack(SubtitleTrack subtitle)
 {
     this.Burned = subtitle.Burned;
     this.Default = subtitle.Default;
     this.Forced = subtitle.Forced;
     this.sourceTrack = subtitle.SourceTrack;
     this.SrtCharCode = subtitle.SrtCharCode;
     this.SrtFileName = subtitle.SrtFileName;
     this.SrtLang = subtitle.SrtLang;
     this.SrtOffset = subtitle.SrtOffset;
     this.SrtPath = subtitle.SrtPath;
     this.SubtitleType = subtitle.SubtitleType;
     this.SourceTrack = subtitle.SourceTrack;
 }
        /// <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 Subitle 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.SubtitleType != SubtitleType.ForeignAudioSearch))
                                      : null);

            if (source == null)
            {
                source = ForeignAudioSearchTrack;
            }

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

            // Burn-in Behaviours
            if (this.SubtitleBehaviours.SelectedBurnInBehaviour == SubtitleBurnInBehaviourModes.ForeignAudio
                  || this.SubtitleBehaviours.SelectedBurnInBehaviour == SubtitleBurnInBehaviourModes.ForeignAudioPreferred)
            {
                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 (track.CanBeBurned)
                {
                    track.Burned = true;
                    this.SetBurnedToFalseForAllExcept(track);
                }
            }

            var encodeTask = this.Task;
            if (encodeTask != null)
            {
                encodeTask.SubtitleTracks.Add(track);
            }
        }
 /// <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);
 }
        /// <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);
        }
 /// <summary>
 /// Remove a Track
 /// </summary>
 /// <param name="track">
 /// The track.
 /// </param>
 public void Remove(SubtitleTrack track)
 {
     this.Task.SubtitleTracks.Remove(track);
 }
        /// <summary>
        /// Import an SRT File.
        /// </summary>
        public void Import()
        {
            OpenFileDialog dialog = new OpenFileDialog
                {
                    Filter = "SRT files (*.srt)|*.srt",
                    CheckFileExists = true,
                    Multiselect = true
                };

            dialog.ShowDialog();

            foreach (var srtFile in dialog.FileNames)
            {
                SubtitleTrack track = new SubtitleTrack
                    {
                        SrtFileName = Path.GetFileNameWithoutExtension(srtFile),
                        SrtOffset = 0,
                        SrtCharCode = "UTF-8",
                        SrtLang = "English",
                        SubtitleType = SubtitleType.SRT,
                        SrtPath = srtFile
                    };
                this.Task.SubtitleTracks.Add(track);
            }
        }