toko214

audio stream

Mar 13th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import pafy
  2. import vlc
  3.  
  4. url = "https://www.youtube.com/watch?v=rfOY8ePOs_0"
  5.  
  6. v = pafy.new(url)
  7. print(v.audiostreams)
  8. s = v.getbestaudio()
  9. print(s.url)
  10. instance = vlc.Instance("--sub-source marq --sout=#stream_out_duplicate{dst=display,dst=std{access=file,mux=ts,dst=stream.webm}}")
  11. p = instance.media_player_new()
  12. media = instance.media_new_location(s.url)
  13. p.set_media(media)
  14. p = vlc.MediaPlayer(s.url)
  15. p.play()
  16. pressed = True
  17. print(str(p.get_length()) + " " + str(p.get_time()))
  18. while True:
  19.     if(p.is_playing()):
  20.         pressed = False
  21.  
  22.     if((p.is_playing()==0) and pressed==False):
  23.         print(str(p.get_length()) + " " + str(p.get_time()))
  24.         print(str(p.is_playing()) + " " + str(pressed))
  25.         break
  26. pass
  27.  
  28. print("FINE")
Add Comment
Please, Sign In to add comment