Question about get_length and get_time

This forum is about all development around libVLC.
bnbtech
New Cone
New Cone
Posts: 2
Joined: 24 Jul 2011 17:26

Question about get_length and get_time

Postby bnbtech » 24 Jul 2011 17:36

Im using libvlc with an H.264 file in an MPEG-2 transport stream. No matter whether the player is playing or paused, libvlc_media_player_get_length and libvlc_media_player_get_time always return 0. Also, any attempts to use libvlc_media_player_set_time are ignored -- the video takes a hit like it's performing a seek but continues playing from the same point. This is with VLC 1.1.10 on OSX 10.6.8. I'm just wondering if this is expected behavior because of the file type and/or codec... if so, is there anything I can do to get this information from this file format using libvlc or am I out of luck? Thanks in advance.

bnbtech
New Cone
New Cone
Posts: 2
Joined: 24 Jul 2011 17:26

Re: Question about get_length and get_time

Postby bnbtech » 24 Jul 2011 19:35

Found my answer... no time information available from VLC for TS files. So, disregard!

lnquang
New Cone
New Cone
Posts: 1
Joined: 05 Dec 2011 00:13

Re: Question about get_length and get_time

Postby lnquang » 05 Dec 2011 00:18

hi, can any one help me with this code, I have trouble to create a slider to control vlc via rc interface, here is the code in autoit:


Func SLIDERClicked()
Local $pos=_GUICtrlSlider_GetPos($Slider);
Local $tpos=$inittime+Round(($pos)*(VLCcmd('get_length'))/1000);
$lastpos=$pos;
if ($tpos>0) then VLCcmd("seek "&$tpos);
ToolTip($tpos);
EndFunc


how to calculate and set correct position of vlc player? the formular tpos seam wrong, when I click it seem jump random, and can not move back to first position (some kind of shift forward only).

thx

nkoriyama
Cone that earned his stripes
Cone that earned his stripes
Posts: 338
Joined: 01 Sep 2011 20:50
VLC version: git
Operating System: Windows / Mac OS X
Location: Japan

Re: Question about get_length and get_time

Postby nkoriyama » 10 Dec 2011 09:39

Found my answer... no time information available from VLC for TS files. So, disregard!
On VLC 1.2 or later, you can get the length(ms) and get current time(ms).
I worked for this future and already it was committed to the trunk tree (1.2.0 or later).
how to calculate and set correct position of vlc player? the formular tpos seam wrong, when I click it seem jump random, and can not move back to first position (some kind of shift forward only).
If you want to calculate correct time and length of MPEG-TS video file, it is not easy.
Because there is no information in stream headers to estimate bitrate or duration.
So, you must parse whole file, at least first and last few packets, to get the duration.
And you cannot get correct time position by the formula:
current_position = stream_position_rate * stream_length
The correlation between time and position is not completely linear.

I don't know anything about AutoIt, but anyway your code seems wrong.
- What is a inittime?
- What is a result of _GUICtrlSlider_GetPos()? a rate(0.0-1.0), a time, a integer(0-1000), or something else?
- What is a result of VLCcmd('get_length')? a time? and a value is not zero? VLC 1.1 always returns zero.
- Does VLCcmd('seek') accept a time as parameter? Generally it's a rate (between 0.0 to 1.0).


If there are commands like VLCcmd('get_time'), you can get more accurate position by the formula:
current_position = get_time / get_length
Of course, you need VLC 1.2.0 or later to get current time and length from MPEG-TS. VLC 1.1 cannot get them.

Maybe, it's time to switch VLC 1.2.0 :D
And I don't know AutoIt supports VLC 1.2.0 or later now :oops:
How To Ask Questions The Smart Way http://www.catb.org/~esr/faqs/smart-questions.html
My hack for ISDB-T http://sdrv.ms/126weue


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 10 guests