Downloading video from YouTube

C#.NetYoutubeYoutube Api

C# Problem Overview


I wish to download a video from YouTube and then extract its audio.

Can anyone point me to some C# code to download a video?

For clarification purposes, I already know how to extract audio from a .FLV file like these.

C# Solutions


Solution 1 - C#

I've written a library that is up-to-date, since all the other answers are outdated:

https://github.com/flagbug/YoutubeExtractor

Solution 2 - C#

You can check out libvideo. It's much more up-to-date than YoutubeExtractor, and is fast and clean to use.

Solution 3 - C#

Gonna give another answer, since the libraries mentioned haven't been actively developed anymore.

Consider using YoutubeExplode. It has a very rich and consistent API and allows you to do a lot of other things with youtube videos beside downloading them.

Solution 4 - C#

I suggest you to take a look into SharpGrabber - a .NET Standard library I've written just for this purpose. It is newer than YouTubeExtractor and libvideo. It supports YouTube and Instagram as the time of this answer. This project also offers high-quality video and audio muxing and a cross-platform desktop application.

Solution 5 - C#

To all interested:

The "Coding for fun" book's chapter 4 "InnerTube: Download, Convert, and Sync YouTube Videos" deals with the topic. The code and discussion are at http://www.c4fbook.com/InnerTube.

[PLEASE BEWARE] While the overall concepts are valid some years after the publication, non-documented details of the youtube internals the project relies on can have changed (see the comment at the bottom of the page behind the second link).

Solution 6 - C#

libvideo https://github.com/omansak/libvideo (aka VideoLibrary) is a modern .NET library for downloading YouTube videos. It is portable to most platforms and is very lightweight.

This is recommended for more downloads and more popularity.

Use it for just few simple codes:

   using VideoLibrary;

   void SaveVideoToDisk(string link)
   {
      var youTube = YouTube.Default; 
      var video = youTube.GetVideo(link); 
      File.WriteAllBytes(@"C:\" + video.FullName, video.GetBytes());
   }

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMaxim ZaslavskyView Question on Stackoverflow
Solution 1 - C#FlagbugView Answer on Stackoverflow
Solution 2 - C#James KoView Answer on Stackoverflow
Solution 3 - C#TyrrrzView Answer on Stackoverflow
Solution 4 - C#JavidView Answer on Stackoverflow
Solution 5 - C#mlvljrView Answer on Stackoverflow
Solution 6 - C#HoseinView Answer on Stackoverflow