Hey, first of all i would thank you for such a great work!
So i used VideoLibrary but since i faced some trouble with downloading exact video i came here...
Please can u edit the following code to download only the sound as mp3 and to save it on desktop, i want to download a video in the fastest way to play it's sound (i would prefer to download it at 480p quality or something near) Thanks in advance!
var url = "https://www.youtube.com/watch?v=Euz1F0MG494";
var id = YoutubeClient.ParseVideoId(url); // "bnsUkE8i0tU"
var client = new YoutubeClient();
var streamInfoSet = await client.GetVideoMediaStreamInfosAsync("bnsUkE8i0tU");
var streamInfo = streamInfoSet.Muxed.WithHighestVideoQuality();
var ext = streamInfo.Container.GetFileExtension();
await client.DownloadMediaStreamAsync(streamInfo, $"downloaded_video.{ext}");
MessageBox.Show("Done");
If you only want audio, use streamInfoSet.Audio.WithHighestBitrate() instead.
I'm working on this project for 3 hours, and I haven't tried to change the quality of the video. But this Issue seems to be interesting, I want to know how to change quality too...
One last thing, how can i save it on desktop (it would be better if i can play it without any need to wait for that), i nearly figured that but it says access to path is denied!
await client.DownloadMediaStreamAsync(streamInfo, Environment.SpecialFolder.Desktop + $".{ext}");
When you click button then:
private void button1_Click(object sender, EventArgs e)
{
DialogResult result = folderBrowserDialog1.ShowDialog(); //Locate to Dekstop
if (result == DialogResult.OK)
{
textBox1.Text = folderBrowserDialog1.SelectedPath;
}
}
Then replace it like this:
await client.DownloadMediaStreamAsync(streamInfo, textBox1.Text + $".{ext}");
You can filter by stream qualities using LINQ, e.g. streamInfoSet.Video.Where(s => s.VideoQuality > VideoQuality.Medium360).Where(s => s.VideoQuality <= VideoQuality.High1080) will filter the video streams to those of quality between 480p and 1080p inclusively.
Most helpful comment
One last thing, how can i save it on desktop (it would be better if i can play it without any need to wait for that), i nearly figured that but it says access to path is denied!