Wrong return values of libvlc_media_player_get_position

This forum is about all development around libVLC.
sleep
New Cone
New Cone
Posts: 2
Joined: 04 Nov 2009 10:22

Wrong return values of libvlc_media_player_get_position

Postby sleep » 29 Jan 2010 10:16

I use the VLC.Interop Wrapper for VLC 1.0.x by Kairos and VLC 1.0.3 libraries in a little Tool to Transcode uncompressed AVI Files into MPEG-2 / H.264 Transport Stream Files. I tried to use the Vlc.TimeChanged Events end read the length, time, position, fps and rate Attributes. I was especially interested to display the transcoding progress by utilizing the position attribute. The Kairos Wrapper uses the following libvlc methods:

Code: Select all

libvlc_media_player_get_length (libvlc_media_player_t *, libvlc_exception_t *) //Get the current movie length (in ms). libvlc_media_player_get_time (libvlc_media_player_t *, libvlc_exception_t *) //Get the current movie time (in ms). libvlc_media_player_get_position (libvlc_media_player_t *, libvlc_exception_t *) //Get movie position. libvlc_media_player_get_fps (libvlc_media_player_t *, libvlc_exception_t *) //Get movie fps rate. libvlc_media_player_get_rate (libvlc_media_player_t *, libvlc_exception_t *) //Get movie play rate.
When I transcoded a test AVI File (1000frames 320*240@25fps) on a P4 Dualcore (2x3,2GHz) machine, it took ~7.2seconds to finish, wich is approximately 5.5 times faster than real time playback. During this transcoding task, I logged the length, time, position, fps and rate values each time the TimeChanged Event was fired.
These are the results:

length: as expected, always '40000' (milliseconds)
time: start: 0, end: 7148; so this is obviously the time in milliseconds that has passed since the playback of the file was started.
position: start: 0.0, end: 0.1787; Very strange! I had expected this value to range from 0.00(start of file / 0%) to 1.00(end of file / 100%). Instead, the maximum value was much lower which leads to the conclusion that the current position is calculated incorrectly using the following formula:

position = time / length;

Using the end values, this assumption was verified: 7148 / 40000 = ...0.1787
This will compute correct values, as long as you just playback videos at their regular playback rate, but will return incorrect values,
as soon as the playback speed differs from 1.0 as it is the case during Transcoding.

To calculate the position percentage correctly, libvlc_media_player_get_position should use the relation between the total file length and current read position.

fps: always 25; okay so thats the nominal fps value of the video
rate: always 1; mmh shouldn't this be the actual playback/ transcoding rate, so in my case ~5.5? If this would return the current playback rate, one could also easily determine the current transcoded fps by multiplying rate * fps.

During debugging I found out that it is definitely NOT the wrapper that returns the controversial values, but the above mentioned libvlc methods.

Has anyone experienced similar issues and can provide help or a workaround for this? Any chance that this will be fixed in the near future?

Greetings

Thomas

Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 25 guests