Skip to content
Related Articles

Related Articles

Python VLC MediaPlayer – Getting Height of selected video

Improve Article
Save Article
Like Article
  • Last Updated : 30 Sep, 2021

In this article, we will see how we can get the height 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. MediaPlayer object is the basic object in vlc module for playing the video. We can create a MediaPlayer object with the help of MediaPlayer method. We can get the height of the selected video by passing the index of the video, if no index is specified ongoing video height is returned.

In order to do this we will use video_get_height method with the MediaPlayer object
Syntax : media_player.video_get_height(n)
Argument : It takes integer as optional argument
Return : It returns integer 
 

Below is the implementation  

Python3




# importing vlc module
import vlc
 
# importing time module
import time
 
 
# creating vlc media player object
media_player = vlc.MediaPlayer()
 
# media resource locator
mrl = "death_note.mkv"
 
# setting mrl to the media player
media_player.set_mrl(mrl)
 
# start playing video
media_player.play()
 
# wait so the video can be played for 5 seconds
# irrespective for length of video
time.sleep(5)
 
# getting height at index 0
value = media_player.video_get_height(0)
 
# printing height
print("Height at Index 0 : ")
print(value)

Output : 

Height at Index 0 : 
720

Another example 

Below is the implementation  

Python3




# importing vlc module
import vlc
 
# importing time module
import time
 
# creating vlc media player object
media_player = vlc.MediaPlayer()
 
# media resource locator
mrl = "1.mp4"
 
# setting mrl to the media player
media_player.set_mrl(mrl)
 
# start playing video
media_player.play()
 
# wait so the video can be played for 5 seconds
# irrespective for length of video
time.sleep(5)
 
# getting height at index 0
value = media_player.video_get_height(0)
 
# printing height
print("Height at Index 0 : ")
print(value)

Output : 

Height at Index 0 : 
480

 


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!