Skip to content
Manojbabu edited this page Mar 16, 2026 · 9 revisions

Ytdlp.NET

Static Badge NuGet Version NuGet Downloads

Ytdlp.NET is an open-source, modern .NET wrapper library for yt-dlp, the popular command-line audio/video downloader and metadata extractor.
It provides a fluent, strongly-typed API to build yt-dlp commands, fetch rich metadata, list formats, monitor progress, and execute downloads with full event support.

Ytdlp.NET
Developer Manojbabu (manusoft/manuhub)
Initial release 2025
Stable release 1.4.0
Preview release 2.0.0-preview1 (February 2026)
Repository github.com/manusoft/yt-dlp-wrapper
Written in C# (.NET 8.0 or later)
License MIT
Website https://github.com/manusoft/yt-dlp-wrapper

Overview

Ytdlp.NET simplifies interaction with yt-dlp by offering:

  • Fluent builder pattern (SetFormat, EmbedMetadata, UseProxy, etc.)
  • Rich metadata parsing via GetVideoMetadataJsonAsync (title, duration, views, thumbnails, formats, chapters, subtitles, etc.)
  • Auto-selection helpers (GetBestAudioFormatIdAsync, GetBestVideoFormatIdAsync)
  • Real-time progress events (OnProgressDownload, OnPostProcessingComplete)
  • Cancellation support with graceful handling
  • Batch & concurrent downloads
  • SponsorBlock, cookies-from-browser, concurrent fragments, custom headers, etc.

It does not bundle yt-dlp — users must install yt-dlp separately (or use companion packages like Ytdlp.Stable.Build).

Features

  • Fluent API — chainable methods for almost all common yt-dlp flags
  • Metadata & Formats — full JSON parsing with strongly-typed Metadata and Format classes
  • Events — progress, errors, completion, post-processing callbacks
  • Progress parsing — percentage, speed, ETA, fragments, merging detection
  • Cancellation — safe CancellationToken support (no stalled processes)
  • Companion packagesYtdlp.FFmpeg.Build, Ytdlp.Stable.Build, etc. for zero-manual-setup
  • .NET Modern — targets .NET 8.0 and .NET 9.0, async-first

Installation

Via NuGet (recommended)

<PackageReference Include="Ytdlp.NET" Version="2.0.0-preview1" />

Companion packages (optional but strongly recommended)

<PackageReference Include="Ytdlp.Stable.Build" Version="*" />
<PackageReference Include="Ytdlp.FFmpeg.Build" Version="*" />
<PackageReference Include="Ytdlp.FFprobe.Build" Version="*" />
<PackageReference Include="Ytdlp.Deno.Runtime" Version="*" /> 

These packages automatically download and extract the latest yt-dlp / FFmpeg binaries into your output folder.

Basic Usage

var ytdlp = new Ytdlp(); // auto-detects yt-dlp from companion packages or PATH

// Download best 1080p video + best audio
await ytdlp
    .SetFormat("bestvideo[height<=1080]+bestaudio/best")
    .SetOutputFolder("./downloads")
    .SetOutputTemplate("%(title)s [%(resolution)s].%(ext)s")
    .EmbedMetadata()
    .EmbedThumbnail()
    .ExecuteAsync("https://www.youtube.com/watch?v=Xt50Sodg7sA");

Auto-select best formats

string bestVideo = await ytdlp.GetBestVideoFormatIdAsync(url, maxHeight: 1080);
string bestAudio = await ytdlp.GetBestAudioFormatIdAsync(url);

await ytdlp
    .SetFormat($"{bestVideo}+{bestAudio}/best")
    .ExecuteAsync(url);

Fetch metadata

var meta = await ytdlp.GetVideoMetadataJsonAsync(url);

Console.WriteLine($"Title: {meta?.Title}");
Console.WriteLine($"Duration: {meta?.Duration} s");
Console.WriteLine($"Views: {meta?.ViewCount:N0}");
Console.WriteLine($"Best thumbnail: {meta?.BestThumbnailUrl}");

Thread Safety & Disposal

  • Ytdlp is not thread-safe
    Do not use the same instance from multiple threads or concurrent tasks.
    Always create a fresh instance per download operation when running in parallel.

    Safe example (concurrent batch):

    var tasks = urls.Select(async url =>
    {
        var y = new Ytdlp(); // new instance per task
        await y.SetFormat("best").ExecuteAsync(url);
    });
    await Task.WhenAll(tasks);

    Unsafe (will cause race conditions):

    var y = new Ytdlp(); // shared instance
    var tasks = urls.Select(u => y.SetFormat("best").ExecuteAsync(u));
    await Task.WhenAll(tasks);
  • Disposal
    In v2.0 the class does not implement IDisposable. Internal resources (e.g. child processes) are cleaned up automatically when the instance is garbage-collected. Proper Dispose support and an immutable builder pattern (for safe reuse) are planned for later.

Dependencies

  • .NET 8.0 or later
  • yt-dlp executable (required)
  • FFmpeg / FFprobe (recommended for merging, audio extraction, thumbnails)

See also

References

  1. GitHub repository: https://github.com/manusoft/yt-dlp-wrapper
  2. yt-dlp releases: https://github.com/yt-dlp/yt-dlp/releases
  3. FFmpeg builds: https://www.gyan.dev/ffmpeg/builds/

This page was last edited on February 15, 2026.

Clone this wiki locally