omansak / libvideo

A lightweight .NET library to download YouTube videos.
BSD 2-Clause "Simplified" License
553 stars 163 forks source link

Download video/music but i dont listenning the sound #179

Closed AndreZila01 closed 3 years ago

AndreZila01 commented 4 years ago

I am Creating an Youtube to MP4 Downloader for Windows in .Net framework / C#. I am using the VideoLibrary to download the Video.

I use code the download, and use File.WriteAllBytes, and when i open the video I dont listenning the music of video.

My code:

private async void DownloadVideo()
{
    string downloadUri;
    String link = TxtUrl.Text;

    if (TxtUrl.Text.Contains("youtu.be/"))
    {
        string[] dss = TxtUrl.Text.Split(new string[] { "youtu.be/" }, StringSplitOptions.None);
        string dsss = dss[0] + "youtube.com/watch?v=" + dss[1];
        link = dsss;
    }
    var videoInfos = await cli.GetAllVideosAsync(link);
    try
    {
        TxtUrl.Text = link; 
        var downloadInfo = videoInfos.Where(i => i.Format == VideoFormat.Mp4 && i.Resolution == int.Parse(cboResolucao.Text)).FirstOrDefault(); // if 720p is possible
        downloadUri = downloadInfo.Uri;
        File.WriteAllBytes(textBox1.Text + @"\" + downloadInfo.FullName, downloadInfo.GetBytes()/*await downloadInfo.GetBytesAsync()*/);
        FULLname = downloadInfo.FullName;
        FULLname = FULLname.Replace(".mp4", "");
    }
}

Thanks for your help!!

omansak commented 4 years ago

720p and above res has no sound.

AndreZila01 commented 4 years ago

Cannot worked, if I use 720p or 360p. I try convert mp4 and mp3, and dont work.