Issues with vlc.input.time not updating

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
JMGirard
New Cone
New Cone
Posts: 2
Joined: 02 Feb 2015 21:46

Issues with vlc.input.time not updating

Postby JMGirard » 02 Feb 2015 22:36

I am using ActiveX to embed VLC 2.1.5 within a MATLAB (R2014b) figure. While playing a video, I want to display the video time stamp multiple times per second using a timer. This all works quite nicely, except that the time stamp does not increment as fast as I'd like. If this were the case, the output would look like: 0.000, 0.100, ... , 2.000. Instead, it seems to repeat certain numbers (as shown below). Is this an issue of how I am querying the time stamp or does it just not update fast enough? Does the update speed vary by computer?

Code: Select all

fig = figure; vlc = actxcontrol('VideoLAN.VLCPlugin.2',[0 0 400 300],fig); t = timer(... 'ExecutionMode','fixedRate', ... 'Period',0.10, ... 'TasksToExecute',20,... 'TimerFcn','disp(vlc.input.time/1000);',... 'StopFcn','vlc.playlist.stop()'); vlc.playlist.add('file://localhost/video.mp4'); vlc.playlist.play(); start(t);
Example Output:

Code: Select all

0.000 0.307 0.601 0.601 0.601 0.903 0.903 0.903 1.202 1.202 1.202 1.502 1.502 1.502 1.800 1.800 1.800 2.102 2.102 2.102 2.401
Last edited by JMGirard on 03 Feb 2015 20:12, edited 2 times in total.

RSATom
Big Cone-huna
Big Cone-huna
Posts: 513
Joined: 24 Nov 2011 06:55
Operating System: Windows/Linux/OsX
Location: Russia, Tomsk

Re: Issues with vlc.input.time not updating

Postby RSATom » 03 Feb 2015 08:38


JMGirard
New Cone
New Cone
Posts: 2
Joined: 02 Feb 2015 21:46

Re: Issues with vlc.input.time not updating

Postby JMGirard » 03 Feb 2015 20:09

Thank you RSATom; the link was helpful. Ideally, VLC would increase its temporal resolution. However, in the meantime, I was able to adapt this work-around:

Code: Select all

function mwe last_ts_vlc = 0; last_ts_sys = 0; fig = figure; vlc = actxcontrol('VideoLAN.VLCPlugin.2',[0 0 400 300],fig); t = timer(... 'ExecutionMode','fixedRate', ... 'Period',0.05, ... 'TasksToExecute',100,... 'TimerFcn',@timer_Callback,... 'StopFcn',@timer_Cleanup); vlc.playlist.add('file://localhost/video.mp4'); a = tic; start(t); vlc.playlist.play(); function timer_Callback(~,~) ts_vlc = vlc.input.time/1000; ts_sys = toc(a); if ts_vlc == last_ts_vlc && last_ts_vlc ~= 0 ts_diff = ts_sys - last_ts_sys; ts_vlc = ts_vlc + ts_diff; fprintf('%f *\n',ts_vlc); else last_ts_vlc = ts_vlc; last_ts_sys = ts_sys; fprintf('%f\n',ts_vlc); end end function timer_Cleanup(~,~) delete(t); end end
I now get output like this:

Code: Select all

0.000000 0.000000 0.379000 0.524026 * 0.547650 * 0.700000 0.796576 * 1.000000 1.036312 * 1.077174 * 1.215125 * 1.240523 * 1.300000 1.442218 * 1.450852 * 1.600000 1.748362 * 1.749543 * 1.820491 * 1.900000 2.200000 2.244058 * 2.500000 2.544737 * 2.687710 * 2.800000 2.817524 * 2.868725 * 3.100000 3.117315 * 3.161042 * 3.295879 * 3.400000 3.530405 * 3.555859 * 3.700000 4.000000 4.024536 * 4.072040 * 4.212366 * 4.300000 4.340622 * 4.363510 * 4.600000 4.701124 * 4.900000 4.948787 * 4.986760 * 5.019817 * 5.165957 * 5.200000 5.500000 5.800000 5.897894 * 5.923710 * 6.086371 * 6.100000 6.101379 * 6.400000 6.582067 * 6.700000 6.726970 * 6.785883 * 6.931990 * 7.000000 7.215887 * 7.300000 7.349231 * 7.535583 * 7.600000 7.795317 * 7.821314 * 7.900000 7.960549 * 8.200000 8.438918 * 8.500000 8.542604 * 8.688697 * 8.800000 8.849015 * 8.868693 * 8.912794 * 9.100000 9.400000 9.700000 9.709693 * 9.758806 * 10.000000 10.078359 * 10.100346 * 10.138720 * 10.300000 10.600000 10.619578 *


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 44 guests