Esempio n. 1
0
    public async Task User_can_download_a_video_with_subtitles_into_a_single_mp4_file()
    {
        // Arrange
        var youtube        = new YoutubeClient();
        var outputFilePath = _tempOutputFixture.GetTempFilePath();

        var streamManifest = await youtube.Videos.Streams.GetManifestAsync("YltHGKX80Y8");

        var trackManifest = await youtube.Videos.ClosedCaptions.GetManifestAsync("YltHGKX80Y8");

        var streamInfos = new[]
        {
            streamManifest.GetVideoStreams().OrderBy(s => s.Size).First(s => s.Container == Container.Mp4)
        };

        var trackInfos = trackManifest.Tracks;

        // Act
        await youtube.Videos.DownloadAsync(
            streamInfos,
            trackInfos,
            new ConversionRequestBuilder(outputFilePath)
            .SetFFmpegPath(_ffmpegFixture.FilePath)
            .SetContainer("mp4")
            .Build()
            );

        // Assert
        MediaFormat.IsMp4File(outputFilePath).Should().BeTrue();

        foreach (var trackInfo in trackInfos)
        {
            FileEx.ContainsBytes(outputFilePath, Encoding.ASCII.GetBytes(trackInfo.Language.Name)).Should().BeTrue();
        }
    }
Esempio n. 2
0
    public async Task User_can_download_a_video_by_merging_best_streams_into_a_single_mp4_file()
    {
        // Arrange
        var youtube        = new YoutubeClient();
        var outputFilePath = Path.ChangeExtension(_tempOutputFixture.GetTempFilePath(), "mp4");

        // Act
        await youtube.Videos.DownloadAsync("AI7ULzgf8RU", outputFilePath);

        // Assert
        MediaFormat.IsMp4File(outputFilePath).Should().BeTrue();
    }
Esempio n. 3
0
    public async Task User_can_download_a_video_with_custom_conversion_settings()
    {
        // Arrange
        var youtube        = new YoutubeClient();
        var outputFilePath = _tempOutputFixture.GetTempFilePath();

        // Act
        await youtube.Videos.DownloadAsync("AI7ULzgf8RU", outputFilePath, o => o
                                           .SetFFmpegPath(_ffmpegFixture.FilePath)
                                           .SetContainer("mp4")
                                           .SetPreset(ConversionPreset.UltraFast)
                                           );

        // Assert
        MediaFormat.IsMp4File(outputFilePath).Should().BeTrue();
    }