get pos gives wrong answer !!

This forum is about all development around libVLC.
nurquhar
New Cone
New Cone
Posts: 4
Joined: 03 Oct 2011 10:18

get pos gives wrong answer !!

Postby nurquhar » 25 Jan 2012 11:37

I have a simple app built using vlc 1.1.11 and VC6. It plays a fixed mpeg2 file which is 36 minutes (2160 secs) in length, of which the the last minute of video is all "black" trailer frames. I am trying to syncronise the playing of the same file on a number of machines using some tcp/ip sockets messages. To do this I am waiting for libvlc_media_player_get_position() to report a value of 0.9985, ie 2156 seconds into the play and then pause, wait for sync, set pos = 0 and then play again. This works fine and gives a smooth roll around. HOWEVER when libvlc reports pos = 0.9985 it is not actually in the 1 minute of black trailer but still in the last 4 seconds of the bit before the black trailer. Its like vlc is ignoring the black trailer play time when reporting its position. :evil: Is this another bug :?:

I have already tried using libvlc_media_player_get_time() but this always reports a value of ZERO. So thats definatly broke. :roll:


Is there a work around I could try ?? :?:

Regards
Neil

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37519
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: get pos gives wrong answer !!

Postby Jean-Baptiste Kempf » 26 Jan 2012 14:05

PS? TS?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

nurquhar
New Cone
New Cone
Posts: 4
Joined: 03 Oct 2011 10:18

Re: get pos gives wrong answer !!

Postby nurquhar » 03 Feb 2012 13:21

PS? TS?
I am sure this answer means something to some people, but for me its two obscure and unknown abreviations. :?:

However for those who may also grapple with the meaning of the number returned by libvlc_media_player_get_position() I have the following guess/understanding of what it means and how it is derived. I should state that I have tried to study any source code, just how it behaves when used.

1. The value is NOT directly proportional to the current play position in terms of either time or frames. i.e. the equation No. of frames played / No. of frames in File != libvlc_media_player_get_position() .

2. I suspect it is actualy calculating a value from a an equation such as : Current Number of Bytes Read From Media File / Size of Media File. Now if you have varying degrees of compression ratios for different sections of your media then the position value calculated will not be proportional to the actual play position. i.e. Where my 1 minute of "black" trailer starts at the end of my 36 min media file I would expect it have very high compression ratio when compared to preceeding 35 minutes. Indeed looking at libvlc_media_player_get_position() for my file it reports a value of 0.998958 when it has a minute left to play. You might have expected a value of 0.9722222 (35/36).

3. This is not just a "feature" of the libvlc libary either. :!: When playing my media file in the regular vlc media player installed on my PC the slider bar does not accuratly show the position into the play either. i.e. The slider moves at regular pace for the first 35 minutes of play but by the time it gets to my 1 minute of black trailer the slider appears to be already at the end and moves no further during the last minute of black trailer.

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

Re: get pos gives wrong answer !!

Postby Rémi Denis-Courmont » 03 Feb 2012 13:30

The value is supposed to be proportional to duration. But different input or file formats have different level of accuracy. Some do not even provide a position at all, such as if the duration is unknown or undefined.
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 1 guest