title: How would I stream audio from pytube to FFMPEG and discord.py without downloading and converting beforehand
body: <p>I have a discord.py bot setup in a small server of mine. I have setup a music command that downloads a song from YouTube and outputs it into a VC. At the moment, the command downloads the full song, converts it, and <em>then</em> outputs it into a VC, but this process is heavily slow. How would I go about streaming the audio directly into the VC? I'm open to use youtube_dl in place of pytube3. I don't care much about smaller code optimizations as this is just a small bot for a few friends and me.</p>
  <p>Thanks for any input!</p>
  <pre><code>@bot.command()
  async def play(ctx, *song):
      if ctx.author.voice is None or ctx.author.voice.channel is None:
          await ctx.send(&quot;You aren't in a VC!&quot;)
          return
      print(song) #debugging
      os.system(&quot;rm music.mp3&quot;)
      ydl_opts = {
          'noplaylist': True,        
          'outtmpl': 'music',
          'postprocessors': [{
              'key': 'FFmpegExtractAudio',
              'preferredcodec': 'mp3',
              'preferredquality': '128',
          }],
      'format': '139',  
      }
      youtube = pytube.YouTube(str(song).strip(&quot;(,)'&quot;))
      video = youtube.streams.filter(only_audio=True).first()
      await ctx.send(&quot;downloading&quot;)
      video.download(filename=&quot;music&quot;)
      await ctx.send(&quot;converting...&quot;)
      os.system(&quot;ffmpeg -i music.mp4 -map 0:a:0 -b:a 96k music.mp3&quot;)
      
      voice_channel = ctx.author.voice.channel
      vc = await voice_channel.connect()
      vc.play(discord.FFmpegPCMAudio('music.mp3'), after=lambda e: print('done', e))
      while vc.is_playing():
          await asyncio.sleep(1)
      await ctx.voice_client.disconnect()
  </code></pre>