vlcj - setting position to mediaPlayer

This forum is about all development around libVLC.
dukw1942
New Cone
New Cone
Posts: 6
Joined: 10 Dec 2010 09:19

vlcj - setting position to mediaPlayer

Postby dukw1942 » 25 Jan 2011 15:37

Hi!

I am having some problems with accuracy when setting current position to media player via setTime(long), setPosition(float) or any other method that changes position of media player. Every time when I want to change current position to desired value, media player sets itself to that position but resets itself to desired value + offset (in my case 190ms) right away. For example, when I call setTime(0), media player sets itself to 190 millisecond. The same happens if I use setPosition(), skip(), ... Thing that bothers me too is that sometimes mentioned methods work just fine (without adding offset). I am using TestPlayer from vlcj test source.
Did I miss something obvious? Any idea? Any advice would help.

Thank you for your help.

gnosygnu
Blank Cone
Blank Cone
Posts: 45
Joined: 06 Jun 2010 16:06

Re: vlcj - setting position to mediaPlayer

Postby gnosygnu » 26 Jan 2011 02:31

I've noticed a few timing issues myself, but these can be traced back to vlc. vlcj just calls libvlc (see code below). You should be able to reproduce against vlc (You should list what version of vlc you are using. I'm using 1.1.4. Also, I'm mostly on Windows XP SP3)

What type of media/file is it? Different file formats will probably pass through different codecs. Offhand, I've noticed the following time issues with vlc:
- mp3s: setTime/setPosition is off on a fractional basis, but accumulates over the length of a file. For example, on a 1 GB mp3 file (approx 12 hours), it can be off by as much as 12/15 seconds when setting position (ex: setting to 11 hours 30 minutes 30 seconds sets instead to 11 hours 30 minutes 45 seconds). This difference will only be 3 or 4 seconds when setting to a position at the 3 hour mark. (Note: these numbers are off the top of my head, so they can be off)
Also, not so much related to setTime/setPosition, but vlc does not play the last .25 seconds of an mp3 file.
- DVDs: setTime/setPosition will generally be incorrect. This has to do with the underlying dvdnav library interpolating sectors to arrive at time. (The right way is pretty hard). However you would probably be off by more than 190 milliseconds....
- mkvs: setting time will always jump to the nearest 3 or 5 second marker. For example, setting time to 40 seconds may set instead to 38 or 43. Never 40. I believe this is an issue with the mkv format, and have seen similar behavior in mplayer/Windows MediaPlayer

Hope this is useful.

Code: Select all

// excerpt from 1.1: uk.co.caprica.vlcj.player.MediaPlayer.java public void setTime(long time) { Logger.debug("setTime(time={})", time); libvlc.libvlc_media_player_set_time(mediaPlayerInstance, time); } public void setPosition(float position) { Logger.debug("setPosition(position={})", position); libvlc.libvlc_media_player_set_position(mediaPlayerInstance, position); }

dukw1942
New Cone
New Cone
Posts: 6
Joined: 10 Dec 2010 09:19

Re: vlcj - setting position to mediaPlayer

Postby dukw1942 » 26 Jan 2011 10:01

Thank you for your answer.
I am using vlcj-1.1.5.1, mostly with win 7. Video container is .mov (codec H264 - MPEG-4 AVC), video is recorded with camera that captures frames at 300fps (but that shouldn't be a problem).

Is there a workaround for this problem? Just hardcoding offset in goTo() function is not a good idea since offset dont occur every time...
I've noticed a few timing issues myself, but these can be traced back to vlc. vlcj just calls libvlc (see code below). You should be able to reproduce against vlc (You should list what version of vlc you are using. I'm using 1.1.4. Also, I'm mostly on Windows XP SP3)

What type of media/file is it? Different file formats will probably pass through different codecs. Offhand, I've noticed the following time issues with vlc:
- mp3s: setTime/setPosition is off on a fractional basis, but accumulates over the length of a file. For example, on a 1 GB mp3 file (approx 12 hours), it can be off by as much as 12/15 seconds when setting position (ex: setting to 11 hours 30 minutes 30 seconds sets instead to 11 hours 30 minutes 45 seconds). This difference will only be 3 or 4 seconds when setting to a position at the 3 hour mark. (Note: these numbers are off the top of my head, so they can be off)
Also, not so much related to setTime/setPosition, but vlc does not play the last .25 seconds of an mp3 file.
- DVDs: setTime/setPosition will generally be incorrect. This has to do with the underlying dvdnav library interpolating sectors to arrive at time. (The right way is pretty hard). However you would probably be off by more than 190 milliseconds....
- mkvs: setting time will always jump to the nearest 3 or 5 second marker. For example, setting time to 40 seconds may set instead to 38 or 43. Never 40. I believe this is an issue with the mkv format, and have seen similar behavior in mplayer/Windows MediaPlayer

Hope this is useful.

Code: Select all

// excerpt from 1.1: uk.co.caprica.vlcj.player.MediaPlayer.java public void setTime(long time) { Logger.debug("setTime(time={})", time); libvlc.libvlc_media_player_set_time(mediaPlayerInstance, time); } public void setPosition(float position) { Logger.debug("setPosition(position={})", position); libvlc.libvlc_media_player_set_position(mediaPlayerInstance, position); }

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcj - setting position to mediaPlayer

Postby sherington » 26 Jan 2011 11:14

Thank you for your answer.
I am using vlcj-1.1.5.1, mostly with win 7.
gnosygnu is asking you which version of vlc you're using. If you try your code with the latest vlc you might see better results.

The fact that you're using vlcj is not relevant to your problem since (as gnosygnu has shown in the earlier post) the vlcj call simply gets passed directly to libvlc.

gnosygnu
Blank Cone
Blank Cone
Posts: 45
Joined: 06 Jun 2010 16:06

Re: vlcj - setting position to mediaPlayer

Postby gnosygnu » 27 Jan 2011 00:32

Yes, as sherington noted, vlc version would be useful, as a vlc developer could confirm whether or not this issue is version-related.

I only have a few H264 - MPEG4 files and I would not notice timing differences of < 1 second. Sorry, but that's all I can offer.

dukw1942
New Cone
New Cone
Posts: 6
Joined: 10 Dec 2010 09:19

Re: vlcj - setting position to mediaPlayer

Postby dukw1942 » 27 Jan 2011 08:33

I have downloaded latest version of vlc for win, thats 1.1.6.

Thank you all for your help

dukw1942
New Cone
New Cone
Posts: 6
Joined: 10 Dec 2010 09:19

Re: vlcj - setting position to mediaPlayer

Postby dukw1942 » 28 Jan 2011 12:42

Forgot to mention that the problem is still here, i guess this is how it works...
I have downloaded latest version of vlc for win, thats 1.1.6.
Thank you all for your help


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 5 guests