public async Task AddSubtitleWithLanguageAndCodecTest(SubtitleCodec subtitleCodec)
        {
            string output = Path.ChangeExtension(Path.GetTempFileName(), FileExtensions.Mkv);
            string input  = Resources.MkvWithAudio;

            var language             = "pol";
            IConversionResult result = await(await FFmpeg.Conversions.FromSnippet.AddSubtitle(input, output, Resources.SubtitleSrt, subtitleCodec, language))
                                       .SetPreset(ConversionPreset.UltraFast)
                                       .Start();


            IMediaInfo outputInfo = await FFmpeg.GetMediaInfo(output);

            Assert.Equal(TimeSpan.FromSeconds(3071), outputInfo.Duration);
            Assert.Single(outputInfo.SubtitleStreams);
            Assert.Single(outputInfo.VideoStreams);
            Assert.Single(outputInfo.AudioStreams);
            Assert.Equal(language, outputInfo.SubtitleStreams.First().Language);

            if (subtitleCodec.ToString() == "copy")
            {
                Assert.Equal("subrip", outputInfo.SubtitleStreams.First().Codec);
            }
            else if (subtitleCodec.ToString() == "ssa")
            {
                Assert.Equal("ass", outputInfo.SubtitleStreams.First().Codec);
            }
            else
            {
                Assert.Equal(subtitleCodec.ToString(), outputInfo.SubtitleStreams.First().Codec);
            }
        }
Esempio n. 2
0
        public async Task AddSubtitleWithCodecTest(SubtitleCodec subtitleCodec)
        {
            string output = Path.ChangeExtension(Path.GetTempFileName(), FileExtensions.Mkv);
            string input  = Resources.MkvWithAudio;

            IConversionResult result = await(await FFmpeg.Conversions.FromSnippet.AddSubtitle(input, output, Resources.SubtitleSrt, subtitleCodec))
                                       .Start();

            IMediaInfo outputInfo = await FFmpeg.GetMediaInfo(output);

            Assert.Equal(51, outputInfo.Duration.Minutes);
            Assert.Single(outputInfo.SubtitleStreams);
            Assert.Single(outputInfo.VideoStreams);
            Assert.Single(outputInfo.AudioStreams);

            if (subtitleCodec.ToString() == "copy")
            {
                Assert.Equal("subrip", outputInfo.SubtitleStreams.First().Codec);
            }
            else if (subtitleCodec.ToString() == "ssa")
            {
                Assert.Equal("ass", outputInfo.SubtitleStreams.First().Codec);
            }
            else
            {
                Assert.Equal(subtitleCodec.ToString(), outputInfo.SubtitleStreams.First().Codec);
            }
        }
        public static string GetSubtitleBaseURL(Guid mediaItemId, EndPointSettings client, out string subMime, out string subExtension)
        {
            SubtitleCodec codec = SubtitleCodec.Unknown;

            subMime      = null;
            subExtension = null;

            if (UseSoftCodedSubtitle(client, out codec, out subMime) == true)
            {
                subExtension = SubtitleHelper.GetSubtitleExtension(codec);
                string subType = codec.ToString();
                return(string.Format(GetBaseResourceURL()
                                     + GetResourceUrl(mediaItemId.ToString(), client.ClientId)
                                     + "&aspect=SUBTITLE&type={0}&file=subtitle.{1}", subType, subExtension));
            }
            return(null);
        }
Esempio n. 4
0
        /// <inheritdoc />
        public ISubtitleStream SetCodec(SubtitleCodec codec)
        {
            string input = codec.ToString();

            return(SetCodec($"{input}"));
        }
Esempio n. 5
0
 /// <inheritdoc />
 public ISubtitleStream SetCodec(SubtitleCodec codec)
 {
     return(SetCodec(codec.ToString()));
 }