[vlc-devel] libvlc: determining media length

jeetu.golani at gmail.com jeetu.golani at gmail.com
Thu Oct 20 20:27:02 CEST 2011


Hi guys,

First since this doesn't tie in directly to vlc development but rather
using libvlc please accept my apologies if this is the wrong list to
be posting this on.

I need to determine the length of .nuv files preferably using a python
script. I've been toying with libvlc v1.1.3 to this end.

The libvlc_media_player_get_length and libvlc_media_player_get_time
functions seem to work but only after I actually play the video. If I
try to call these functions without playing the media file the
returned value is -1.


So some python code that demonstrates how I am using libvlc currently is:

instance = Instance()
media = instance.media_new("1000_20111003230500.nuv")
player = instance.media_player_new()
player.set_media(media)
player.play()                                         # ideally I
would like the length without playing the file
print media.get_duration()

Is it possible for me to either have the length of the media without
playing it and am I simply doing something wrong? or as a workaround
somehow playing it in memory without it displaying to the user? Or do
newer versions (or the latest master) of libvlc and their python
bindings allow me to retrieve the length without the need to play the
media?

Thanks so much for your help....truly appreciate any light you can shed :)

Bye for now



More information about the vlc-devel mailing list