ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.29k stars 10.03k forks source link

Does youtube-dl have slight delay on start? #21580

Closed XezolesS closed 5 years ago

XezolesS commented 5 years ago

Checklist

Question

I'm trying to make discord bot written in C# and trying to use youtube-dl to play audio from youtube. But when the youtube-dl is executed, it delayed about 4 seconds to run. I want this process run immediately. I don't know whether it is a natural thing or not. Is there any way to fix this?

Here's my arguments in case it needed.

this is for download youtube video.

Process prcs = Process.Start(new ProcessStartInfo
{
    FileName = "cmd",
    Arguments = $"/C youtube-dl -o - \"{url}\" | ffmpeg -hide_banner -loglevel panic -i pipe:0 -ac 2 -f s16le -ar 48000 pipe:1",
    UseShellExecute = false,
    RedirectStandardOutput = true,
    CreateNoWindow = true
});

and this is for getting the information of youtube video.

Process prcs = Process.Start(new ProcessStartInfo
{
    FileName = "youtube-dl",
    Arguments = $"-q -s --get-title --get-duration \"{url}\"",
    UseShellExecute = false,
    RedirectStandardOutput = true,
    CreateNoWindow = true
});
dstftw commented 5 years ago

On slow machine it may take some time to start. Lazy extractors feature may reduce it to some extent.