Exemplo n.º 1
0
        // private Process CreateStream()
        // {
        //     return Process.Start(new ProcessStartInfo
        //     {
        //         FileName = "ffmpeg",
        //         Arguments = "-v verbose -report -probesize 2147483647 -i test -ac 2 -ar 48000 -f s16le pipe:1",
        //         UseShellExecute = false,
        //         RedirectStandardOutput = true,
        //         RedirectStandardInput = true,
        //         RedirectStandardError = true,

        //     });
        // }

        private async Task SendAsync(IAudioClient client, Video video)
        {
            var a = await GetManifestAsync(video);

            IStreamInfo info = a.GetAudioOnly().WithHighestBitrate();
            await youtube.Videos.Streams.DownloadAsync(info, "test");


            //using (var ytVideo = await youtube.Videos.Streams.GetAsync(streamInfo))
            using (var ffmpeg = FFmpegUtils.CreateFFmpeg(fFmpegArguments))
                using (var output = ffmpeg.StandardOutput.BaseStream)
                    //using (var input = ffmpeg.StandardInput.BaseStream)
                    using (var discord = client.CreatePCMStream(AudioApplication.Mixed))
                    {
                        try
                        {
                            await output.CopyToAsync(discord);
                        }
                        catch (Exception e)
                        {
                            System.Console.WriteLine(e.ToString());
                        }
                        finally { await discord.FlushAsync(); }
                    }
        }
Exemplo n.º 2
0
 private async Task PlayAudioClip(IAudioClient audioClient, string path)
 {
     using (var ffmpeg = FFmpegUtils.CreateFFmpeg(ffmpegArguments.WithInputFile(path)))
         using (var output = ffmpeg.StandardOutput.BaseStream)
             using (var discord = audioClient.CreatePCMStream(AudioApplication.Mixed))
             {
                 try { await output.CopyToAsync(discord); }
                 finally { await discord.FlushAsync(); }
             }
 }