Giter Club home page Giter Club logo

youtubeexplode.converter's Introduction

YoutubeExplode.Converter

Build Coverage Version Downloads Discord Donate

⚠️ Project status: maintenance mode (bug fixes only).

➡ The contents of this repository have been moved to YoutubeExplode.

YoutubeExplode.Converter is an extension package for YoutubeExplode that provides an interface to download and mux videos directly using FFmpeg.

Download

📦 NuGet: dotnet add package YoutubeExplode.Converter

Usage

Note that this library relies on FFmpeg binaries, which you can download here. By default, YoutubeExplode.Converter will look for FFmpeg in the probe directory (where the application's dll files are located), but you can also specify the exact location as well.

Downloading a video in highest quality

YoutubeExplode.Converter can be used through one of the extension methods provided on VideoClient. For example, to download a video in the best available quality, simply call DownloadAsync(...) with the video ID and the destination file path:

using YoutubeExplode;
using YoutubeExplode.Converter;

var youtube = new YoutubeClient();
await youtube.Videos.DownloadAsync("https://youtube.com/watch?v=u_yIGGhubZs", "video.mp4");

Under the hood, this resolves available media streams and selects the best candidates based on bitrate, quality, and framerate. If the specified output format is a known audio-only container (e.g. mp3 or ogg) then only the audio stream is downloaded.

Resource usage and execution time depends mostly on whether transcoding between streams is required. When possible, use streams that have the same container as the output format (e.g. mp4 audio/video streams for mp4 output format). Currently, YouTube only provides adaptive streams in mp4 or webm containers, with highest quality video streams (e.g. 4K) only available in webm.

Custom conversion options

You can configure various aspects pertaining to the conversion process by using one of the overloads of DownloadAsync(...):

using YoutubeExplode;
using YoutubeExplode.Converter;

var youtube = new YoutubeClient();

await youtube.Videos.DownloadAsync(
    "https://youtube.com/watch?v=u_yIGGhubZs",
    "video.mp4",
    o => o
        .SetFormat("webm") // override format
        .SetPreset(ConversionPreset.UltraFast) // change preset
        .SetFFmpegPath("path/to/ffmpeg") // custom FFmpeg location
);

Specifying streams manually

If you need precise control over which streams are used for conversion, you can specify them directly as well:

using YoutubeExplode;
using YoutubeExplode.Videos.Streams;
using YoutubeExplode.Converter;

var youtube = new YoutubeClient();

// Get stream manifest
var streamManifest = await youtube.Videos.Streams.GetManifestAsync("u_yIGGhubZs");

// Select streams (1080p60 / highest bitrate audio)
var audioStreamInfo = streamManifest.GetAudioStreams().GetWithHighestBitrate();
var videoStreamInfo = streamManifest.GetVideoStreams().First(s => s.VideoQuality.Label == "1080p60");
var streamInfos = new IStreamInfo[] { audioStreamInfo, videoStreamInfo };

// Download and process them into one file
await youtube.Videos.DownloadAsync(streamInfos, new ConversionRequestBuilder("video.mp4").Build());

youtubeexplode.converter's People

Contributors

tyrrrz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.