Wrong media duration after parsing MPG file

This forum is about all development around libVLC.
asethone
New Cone
New Cone
Posts: 5
Joined: 30 Jun 2023 18:27

Wrong media duration after parsing MPG file

Postby asethone » 18 Oct 2023 14:59

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?

Rémi Denis-Courmont
Developer
Developer
Posts: 15271
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Wrong media duration after parsing MPG file

Postby Rémi Denis-Courmont » 18 Oct 2023 17:52

Some files format don't carry duration in the headers.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

asethone
New Cone
New Cone
Posts: 5
Joined: 30 Jun 2023 18:27

Re: Wrong media duration after parsing MPG file

Postby asethone » 19 Oct 2023 13:29

Thanks for answer!
So there is no methods of retrieving duration from such mediafiles before you start to playback them?

Rémi Denis-Courmont
Developer
Developer
Posts: 15271
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Wrong media duration after parsing MPG file

Postby Rémi Denis-Courmont » 19 Oct 2023 17:15

Sometimes no
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 18 guests