Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

YouTube Audio / Video downloader [VEVO videos, audio: MP3, AAC, Ogg, etc.]

[Image: e09e86bf36647d0d209f4f413d1b90ca.png]

Features
  • Downloads videos from YouTube

  • Allows you to choose the video quality

  • Converts videos to various sound file formats (AAC, MP3, Ogg Vorbis, FLAC, WAV, Direct copy) using FFMPEG



Please tell me if it fails to download some videos. I haven't tried it with that many.

Usage
If you want to download a video:
  1. Copy&paste the YouTube video link (form: http://www.youtube.com/watch?v=XX) into the topmost box

  2. Click the "Download video info" button

  3. Choose the desired video quality from dropdown menu

  4. Click "Download video" and choose the location



If you want to download a video and convert it to audio file
  1. Copy&paste the YouTube video link (form: http://www.youtube.com/watch?v=XX) into the topmost box

  2. Click the "Download video info" button

  3. Choose the desired video quality (this affects the audio quality, you can see the codec and bit rate for audio, too) from dropdown menu.

  4. Choose the audio encoding you want using the other dropdown menu

  5. Click "Download and convert" and choose the location for the audio file


You can also extract audio from already downloaded video (or you can convert audio files into another form) by choosing the target audio encoding from the menu and clicking "Open file and convert"

Download
Link:
http://hostr.co/VLePQbxZaf5F

Requires following
  1. You NEED to download FFMPEG ( http://ffmpeg.org/download.html / http://ffmpeg.zeranoe.com/builds/ ) and place ffmpeg.exe into same folder with this program.
    The reason I'm not redistributing FFMPEG myself has to do with licensing and possible patent issues.

  2. .NET 4.5 Framework: http://www.microsoft.com/visualstudio/en...s#d-net-45

  3. OPTIONAL: For higher quality AAC encoding, you need to download following: http://www.nero.com/enu/company/about-ne...-codec.php and put neroAacEnc.exe also in same folder with my program


Nice release dude :), you made a good work
Updated
  • When saving video/audio files, proper file extension for the file format is automatically appended if not specified by user

  • Added AAC audio support


Why not sharing the source in the download ?

I think this could interest some members..
(Mar 16, 2013 08:31 AM)Antagonism Wrote:  Why not sharing the source in the download ?

I think this could interest some members..

He's using the FFMPEG wrapper, which pretty much takes care of the conversion functionality, so that leaves the YouTube downloading functionality and other miscellaneous things like the GUI. So I don't see much use in releasing the source.

Anywho, thanks OP for the nifty tool, I assume you're using an online service for the youtube download feature?
(Mar 17, 2013 02:22 AM)ifconfig Wrote:  He's using the FFMPEG wrapper, which pretty much takes care of the conversion functionality, so that leaves the YouTube downloading functionality and other miscellaneous things like the GUI. So I don't see much use in releasing the source.

Anywho, thanks OP for the nifty tool, I assume you're using an online service for the youtube download feature?

The download feature is done in the code, there is no online service used.
I did not see you credit this guy.. Which is where most of your code comes from... https://github.com/flagbug/YoutubeExtrac...esolver.cs

Its almost an exact rip..
thank you for this, I really need a faster alternative to those web services that do this. Do you plan on making this opensourced? that would be awesome!
MAKE REP GREAT AGAIN 2027
(Mar 17, 2013 09:22 AM)DotNetNut Wrote:  I did not see you credit this guy.. Which is where most of your code comes from... https://github.com/flagbug/YoutubeExtrac...esolver.cs

Its almost an exact rip..

I haven't ripped anything and you can see that my code isn't even close to that:
(This is the YouTube download class, feel free to use it. And the tuple stuff, yes I know it's not the cleanest :P)
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace YtDownloader
{
    public class YoutubeVideoDownloader
    {
  public event EventHandler<DownloadProgressChangedEventArgs> DownloadProgressChanged;

  /// <summary>
  /// Return information about a video
  /// </summary>
  /// <param name="vid">Video id</param>
  /// <returns>Tuple where the first item is video title and second item is a list of tuples of form: itag, resolution/quality string, video download URL</returns>
  public async Task<Tuple<string, List<Tuple<int, string, string>>>> DownloadVideoInfo(string vid)
  {
    var webClient = new WebClient();

    webClient.Headers.Add("Referer: http://www.youtube.com/");
    await
    webClient.DownloadStringTaskAsync(
    string.Format("http://www.youtube.com/watch?v={0}&gl=US&hl=en&has_verified=1", vid));
    string videoInfo =
    await
    webClient.DownloadStringTaskAsync(
    string.Format(
    "http://www.youtube.com/get_video_info?&video_id={0}&el=vevo&ps=default&eurl=&gl=US&hl=en", vid));

    var parsedVideoInfo = HttpUtility.ParseQueryString(videoInfo);
    var fmtMap = HttpUtility.ParseQueryString(parsedVideoInfo["url_encoded_fmt_stream_map"]);
    var fmtSplitted = parsedVideoInfo["url_encoded_fmt_stream_map"].Split(',');

    var results = new List<Tuple<int, string, string>>();

    if (fmtSplitted.Length > 0 && HttpUtility.ParseQueryString(fmtSplitted[0]).AllKeys.Contains("sig"))
    {
    // sigs & urls in strings
    foreach (var str in fmtSplitted)
    {
    var parsedStr = HttpUtility.ParseQueryString(str);

    results.Add(
    new Tuple<int, string, string>(
    int.Parse(parsedStr["itag"]), GetDimension(int.Parse(parsedStr["itag"])),
    parsedStr["url"] + "&signature=" + parsedStr["sig"]));
    }

    }
    else
    {
    throw new Exception("Unable to parse");
    }

    return new Tuple<string, List<Tuple<int, string, string>>>(parsedVideoInfo["title"], results);
  }

  public async Task DownloadVideoAsync(string vid, string outputFile, string url, int itag)
  {
    var webClient = new WebClient();
    webClient.DownloadProgressChanged += (s, ea) =>
  {
  if (DownloadProgressChanged != null)
  DownloadProgressChanged(s, ea);
  };

    webClient.Headers.Add("Referer: http://www.youtube.com/");
    await webClient.DownloadFileTaskAsync(url, outputFile);
  }

  public string GetDimension(int itag)
  {
    switch (itag)
    {
    case 5:
    return "FLV/240p - MP3/64kbps";
    case 6:
    return "FLV/270p - MP3/64kbps";
    case 13:
    return "3GP/- - AAC";
    case 17:
    return "3GP/144p - AAC/24kbps";
    case 18:
    return "MP4/270p - AAC/96kbps";
    case 22:
    return "MP4/720p - AAC/192kbps";
    case 34:
    return "FLV/360p - AAC/128kbps";
    case 35:
    return "FLV/480p - AAC/128kbps";
    case 36:
    return "3GP/240p - AAC/38kbps";
    case 37:
    return "MP4/1080p - AAC/192kbps";
    case 38:
    return "MP4/3072p - AAC/192kbps";
    case 43:
    return "WebM/360p - Vorbis/128kbps";
    case 44:
    return "WebM/480p - Vorbis/128kbps";
    case 45:
    return "WebM/720p - Vorbis/192kbps";
    case 46:
    return "WebM/1080p - Vorbis/192kbps";
    case 82:
    return "MP4/360p - AAC/96kbps";
    case 83:
    return "MP4/240p - AAC/96kbps";
    case 84:
    return "MP4/720p - AAC/152kbps";
    case 85:
    return "MP4/520p - AAC/152kbps";
    case 100:
    return "WebM/360p - Vorbis/128kbps";
    case 101:
    return "WebM/360p - Vorbis/192kbps";
    case 102:
    return "WebM/720p - Vorbis/192kbps";
    case 120:
    return "FLV/720p - AAC/128kbps";
    }
    return "Unknown (" + itag + ")";
  }
    }
}
(Mar 17, 2013 12:20 PM)hgdfhsdgdfgdfh Wrote:  It's not similar at all... I haven't ripped anything and you can even see that my code isn't even close to that if you use Reflector.

I did use reflector hence how i saw your code, i noticed some VERY similar layout, you may have changed a few things and added an option to download using FFMPEG, but the code looks almost exact at certain parts..

Also why did you not include the ffmpeg in resources? would be easier. It's what i did in my own version. Mine is totally different tho, as i had help from IDB.

If I'm wrong i appolagise. I just copied some of your code into google and that was the result. So it must be exact in the parts i copied or i would not of got an exact result.
(Mar 17, 2013 12:24 PM)DotNetNut Wrote:  I did use reflector hence how i saw your code, i noticed some VERY similar layout, you may have changed a few things and added an option to download using FFMPEG, but the code looks almost exact at certain parts..

Also why did you not include the ffmpeg in resources? would be easier. It's what i did in my own version. Mine is totally different tho, as i had help from IDB.

If I'm wrong i appolagise. I just copied some of your code into google and that was the result. So it must be exact in the parts i copied or i would not of got an exact result.

I posted the class. Everybody can draw their own conclusions on if this is ripped or not.
And the reason for not including FFMPEG is that it might be against the license / patent rules (patent holders of some codecs can demand money for distributing their codecs)
(Mar 17, 2013 12:24 PM)DotNetNut Wrote:  I did use reflector hence how i saw your code, i noticed some VERY similar layout, you may have changed a few things and added an option to download using FFMPEG, but the code looks almost exact at certain parts..

Also why did you not include the ffmpeg in resources? would be easier. It's what i did in my own version. Mine is totally different tho, as i had help from IDB.

If I'm wrong i appolagise. I just copied some of your code into google and that was the result. So it must be exact in the parts i copied or i would not of got an exact result.

Oh god 0xDEADDEAD's source looks so much like the one on the github repository.

Spoiler (Click to View)
https://github.com/Washi1337

"I'll tell you this UDP joke, and I don't care if you will get it or not."
(Mar 17, 2013 12:43 PM)Washi Wrote:  Oh god 0xDEADDEAD's source looks so much like the one on the github repository.

Spoiler (Click to View)

Please note...

I also said "If I'm wrong i appolagise. "

And i can see i am wrong...No need to be a dick about it. I just asked a question, it got answered..
Just a tip I figured out.
If you want to get the best sound quality possible, you should obviously download the video with the biggest audio bitrate. The video resolution doesn't matter. So for example if you have a video with 1080p and 720p (both have audio bitrate 192kbps), you can download the 720p one. And when it comes to the target audio format, for the best quality you should select "Copy (copy audio to container specified by file extension)" from the dropdown menu. If the video you are downloading has AAC sound, set the file extension to ".m4a". If the video has Vorbis sound, file extension should be ".ogg". By using this "Copy" option, you will get the original audio from the video instead of recompressing it again (it can lead to reduced sound quality even if you choose a high quality codec)
[Image: e09e86bf36647d0d209f4f413d1b90ca.png]

Update: Uploaded a new version with more detailed information about audio codecs. Also moved the most HQ (Copy audio) audio 'encoding' to be the default one on the list.
Download: http://hostr.co/VLePQbxZaf5F

Note: FFmpeg is still required: http://ffmpeg.zeranoe.com/builds/ (you need ffmpeg.exe in same folder with my program)
You can also download http://www.nero.com/enu/company/about-ne...-codec.php and place neroAacEnc.exe file into same folder with my program (just as you do with ffmpeg.exe). Note that this step is optional, but recommended if you want to encode high-quality AAC files.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by ZeakZNov 17, 2018 09:53 AM 22 819 Nov 17, 2018 09:53 AM
Last Post: ZeakZ
[C#] by flAmingw0rmSep 30, 2018 03:05 PM 21 1,580 Sep 30, 2018 03:05 PM
Last Post: momo00
[.NET] by iphone5sNov 18, 2017 02:58 PM 3 477 Nov 18, 2017 02:58 PM
Last Post: System[X]