Playing Youtube Video using Python Last Updated : 29 Aug, 2020 Comments Improve Suggest changes Like Article Like Report In this article, we will see how we can play youtube video in python. In order to play youtube videos in python we need pafy and vlc module. Pafy is a Python library to download YouTube content and retrieve metadata. Below is the command to install pafy pip install pafy VLC : is a python library to use the functionality of the vlc media player. In order to use the vlc module in python the user system should have a compatible version of VLC player as well. Below is the command to install vlc module pip install python-vlc Steps for implementation : 1. Import the pafy and vlc module 2. Create a variable having URL of the video 3. Create a pafy object using the link 4. Get the best quality stream of the given youtube link 5. Create a vlc MediaPlayer object by passing the best Stream 6. Play the video Below is the implementation Python3 1== # importing vlc module import vlc # importing pafy module import pafy # url of the video url = "https://www.youtube.com/watch?v = vG2PNdI8axo" # creating pafy object of the video video = pafy.new(url) # getting best stream best = video.getbest() # creating vlc media player object media = vlc.MediaPlayer(best.url) # start playing video media.play() Output : Another example Python3 1== # importing vlc module import vlc # importing pafy module import pafy # url of the video url = "https://www.youtube.com/watch?v=il_t1WVLNxk&list=PLqM7alHXFySGqCvcwfqqMrteqWukz9ZoE" # creating pafy object of the video video = pafy.new(url) # getting stream at index 0 best = video.streams[0] # creating vlc media player object media = vlc.MediaPlayer(best.url) # start playing video media.play() Output : Comment More infoAdvertise with us Next Article Playing Youtube Video using Python R rakshitarora Follow Improve Article Tags : Python Python vlc-library Practice Tags : python Similar Reads Python | Play a video using OpenCV OpenCV (Open Source Computer Vision) is a computer vision library that contains various functions to perform operations on Images or videos. OpenCV library can be used to perform multiple operations on videos. Letâs see how to play a video using the OpenCV Python. To capture a video, we need to crea 2 min read Python | Play a video in reverse mode using OpenCV OpenCV (Open Source Computer Vision) is a computer vision library that contains various functions to perform operations on Images or videos. OpenCV's application areas include : 1) Facial recognition system 2) motion tracking 3) Artificial neural network 4) Deep neural network 5) video streaming etc 3 min read PyQtGraph â Showing Video In this article, we will see how we can show the video in PyQTGraph. PyQtGraph is a graphics and user interface library for Python that provides functionality commonly required in designing and science applications. Its primary goals are to provide fast, interactive graphics for displaying data (plo 4 min read Creating a Slow Motion Video Using OpenCV - Python In this article, we will try to create a slow-motion video using OpenCV( Open Source Computer Vision) library in Python. OpenCV ( is an open-source computer vision and machine learning software library. Now a video is basically a set of moving pictures moving at a rate of about 24 frames per second 4 min read Python VLC MediaPlayer â Setting Subtitle In this article we will see how we can set current subtitle for media of the MediaPlayer object in the python vlc module. VLC media player is a free and open-source portable cross-platform media player software and streaming media server developed by the VideoLAN project. MediPlyer object is the bas 2 min read Convert Audio to Video using Static Images in Python In this article, we are going to convert an audio file(mp3)  to a video file(mp4) using the images provided by the user to be shown during the duration of the video using Python. To do this, we will first convert the images to a GIF file and then combining with the audio file to produce the final vi 5 min read MoviePy â Saving Video File as GIF In this article we will see how we can save video file clip as GIF in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIFâs. Video is formed by the frames, combination of frames creates a video each frame is an individual image. The Graphic 2 min read Python - Writing to video with OpenCV In this article, we will discuss how to write to a video using OpenCV in Python. ApproachImport the required libraries into the working space.Read the video on which you have to write. Syntax: cap = cv2.VideoCapture("path")Create a output file using cv2.VideoWriter_fourcc() method Syntax: output = c 1 min read Python VLC MediaPlayer â Setting Track In this article we will see how we can set track of the MediaPlayer object in the python vlc module. VLC media player is a free and open-source portable cross-platform media player software and streaming media server developed by the VideoLAN project. MediPlyer object is the basic object in vlc modu 2 min read MoviePy âSaving Video File Clip In this article we will see how we can save a video file clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF's. Visual multimedia source that combines a sequence of images to form a moving picture. The video transmits a signal to a 2 min read Like