Page 1 of 1

Wrong media duration after parsing MPG file

Posted: 18 Oct 2023 14:59
by asethone
Hi!

I'm using libVLC 3.0.18 build (without some network plugins) for local media playback in my own app.
Mostly, it is doing good, but recenlty I noticed that duration of MPG files doesn't calculated correctly just after media parsing.

I call libvlc_media_parse_with_options(pMedia, libvlc_media_parse_local, -1) on every media in playlist to display their durations inside the playlist before playing them.
For most of file extentions durations are correct, but for MPG files function libvlc_media_get_duration(pMedia) just returns 0 after parsing.

Parsing process finishes without fails (I have checked for libvlc_media_parse_with_options() return code).
There is some logs:

Code: Select all

main input debug: Creating an input for preparsing 'sample.avi' main meta fetcher debug: looking for meta fetcher module matching "any": 0 candidates main meta fetcher debug: no meta fetcher modules main art finder debug: looking for art finder module matching "any": 1 candidates main art finder debug: no art finder modules matched PARSED DURATION: 16000 main input debug: Creating an input for preparsing 'sample.mpg' main meta fetcher debug: looking for meta fetcher module matching "any": 0 candidates main meta fetcher debug: no meta fetcher modules main art finder debug: looking for art finder module matching "any": 1 candidates main art finder debug: no art finder modules matched PARSED DURATION: 0

You can see that duration from AVI file was calculated successfully, but for MPG file it is zero, though debug messages are absolutely identical.
What is even strager is that when I start playing these MPG files they are played just as normal, and when I try to get their duration AFTER starting playback I get the correct duration values.

What could be the reason of wrong MPG media durations after parsing them? And how else can I get correct duration values BEFORE I start media playback?

Re: Wrong media duration after parsing MPG file

Posted: 18 Oct 2023 17:52
by Rémi Denis-Courmont
Some files format don't carry duration in the headers.

Re: Wrong media duration after parsing MPG file

Posted: 19 Oct 2023 13:29
by asethone
Thanks for answer!
So there is no methods of retrieving duration from such mediafiles before you start to playback them?

Re: Wrong media duration after parsing MPG file

Posted: 19 Oct 2023 17:15
by Rémi Denis-Courmont
Sometimes no