I am developing a headless application on a Raspberry Pi Zero 2 W, Bullseye OS, and using VLC
(Python) to view video files (h264). I have loaded vlc
and python-vlc
. I am able to view videos using the play/stop commands, but have to put a timer in between the commands, because I don't know the actual length of the videos.
I have seen get_length() used in a couple of online vlc
examples, but I get an error on my system.
AttributeError: 'MediaListPlayer' object has no attribute 'get_length'
Here is my relevant code:
video_file = '/var/tmp/video.h264'
instance = vlc.Instance("--verbose=0","--no-xlib","--vout=mmal_vout")
media_list = instance.media_list_new([video_file])
list_player = instance.media_list_player_new()
list_player.set_media_list(media_list)
duration = list_player.get_length() # Without this line, the video plays
list_player.play()
time.sleep(TriggerOnTime.seconds + (TriggerOnTime.microseconds / 1000000) + 1)
list_player.stop()
What am I missing?
I expect to load a time in "duration".