[vlc-devel] [solved] libvlc: determining media length

jeetu.golani at gmail.com jeetu.golani at gmail.com
Fri Oct 21 21:18:28 CEST 2011


Hi guys,

Thought I'd post my workaround to determining the video length of a
nuv in case someone needs this in the future.

As Remi pointed out apparently for libvlc 1.1.3 (not sure of other
versions) and nuv you need to trigger a play before you have the
actual length. I didn't want the display of the user to be visually
presented to the user. Apparently if you trigger a play immediately
followed by a stop, that seems to be enough to be able to then get the
correct file size :)

Therefore something like :

instance = Instance()
media = instance.media_new("1000_20111003230500.nuv")
player = instance.media_player_new()
player.set_media(media)
player.play()
player.stop()
print media.get_duration()

:)

Bye for now

On Fri, Oct 21, 2011 at 12:18 AM, jeetu.golani at gmail.com
<jeetu.golani at gmail.com> wrote:
> Hi Remi,
>
> Thanks so much for your quick reply...truly appreciate it :)
>
>> function can or cannot determine different input item meta infos. However, in
>> general, this is asynchronous, so some formats only provide length after
>> playback starts.
>
> I'm interested specifically in MythTV generated nuv (nupplevideo) file
> format. Is there any workaround possible where I play the file for a
> short duration but it is not visually rendered, maybe played only in
> memory or some other workaround?
>
> Thank you so much again :)
>
> Bye for now
>
> 2011/10/21 Rémi Denis-Courmont <remi at remlab.net>:
>> Le jeudi 20 octobre 2011 21:27:02 jeetu.golani at gmail.com, vous avez écrit :
>>> 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.
>>
>> Depending on the file format and the VLC implementation, the LibVLC preparse
>> function can or cannot determine different input item meta infos. However, in
>> general, this is asynchronous, so some formats only provide length after
>> playback starts.
>>
>> --
>> Rémi Denis-Courmont
>> http://www.remlab.net/
>> http://fi.linkedin.com/in/remidenis
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> http://mailman.videolan.org/listinfo/vlc-devel
>>
>



More information about the vlc-devel mailing list