Getting video file duration

This forum is about all development around libVLC.
shavlo
New Cone
New Cone
Posts: 6
Joined: 24 Feb 2021 10:23

Getting video file duration

Postby shavlo » 28 Oct 2021 15:02

I'm trying to determine video file duration, but for some odd reason the libvlc_media_get_duration function returns odd values e.g. $39100000000000 or similar huge numbers, always with lower bits set to zeros.

The essential part of the code I use

Code: Select all

vlcMedia := libvlc_media_new_path(vlcInstance, PAnsiChar(T)); p_em := libvlc_media_event_manager(vlcMedia); Event := TEvent.Create(nil, False, False, ''); libvlc_event_attach(p_em, NativeInt(libvlc_MediaParsedChanged), ParseChangeEvent, Pointer(Event)); libvlc_media_parse_with_options(vlcMedia, libvlc_media_parse_local, 0); Event.WaitFor(CTimeout); libvlc_event_detach(p_em, NativeInt(libvlc_MediaParsedChanged), ParseChangeEvent, Pointer(Event)); if libvlc_media_get_parsed_status(vlcMedia) = libvlc_media_parsed_status_done then Len := libvlc_media_get_duration(vlcMedia);
The event is set in the callback, the return value of the libvlc_media_get_parsed_status shows that the parsing is done, but duration is not returned correctly. What am I doing wrong?

I've tried another approach with playing the file first, then stopping.
libvlc_media_player_get_length - returns the correct duration
libvlc_media_get_duration - returns garbage

Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 6 guests

cron