adding a time-seek feature.

Discussion about configuration and usage of VLM (a stream scheduler) within VLC.
igorh
Blank Cone
Blank Cone
Posts: 14
Joined: 04 Oct 2006 23:45
Location: Massachusetts, USA

adding a time-seek feature.

Postby igorh » 01 Nov 2006 00:44

For some of the work I am doing, i needed a way to seek to a msec position in a VLM stream (not just percentage). i have added a new control command to allow me to do that, called msecseek. The code changes are minor, isolated to /src/misc/vlm.c. i have tested this for both 0.8.6 and 0.9.0 on my Windows machine and they seem pretty solid (the code basically does what seek does but changing the time instead of the position.) It also works both from the http & telnet interfaces.

Is this a feature that would be useful to anyone else (i saw defect 465, which may be this functionality). If so, is this something that can get into 0.8.6 or is there a code-freeze for that branch already?

If this is useful to people, I'll send a patch to the mailing list.

funman
Developer
Developer
Posts: 1159
Joined: 03 Sep 2006 04:03
VLC version: master
Operating System: All of them
Location: Lost, please help me

Postby funman » 01 Nov 2006 11:17

Hi

for 0.8.6 it is too late to introduce new features, unless they are very short and can be verified as bug free

however that could be useful for later releases

you can of course send it to vlc-devel mailing list ;)

igorh
Blank Cone
Blank Cone
Posts: 14
Joined: 04 Oct 2006 23:45
Location: Massachusetts, USA

patches

Postby igorh » 10 Nov 2006 00:42

Here's the patch for trunk (and below it for 0.8.6, if there a chance to get that in). As you can see from the code, it's very simple, and mirrors existing functionality. I would appreciate your help putting this into the code base.

Thanks again,
-igor

trunk patch

Code: Select all

--- src/misc/vlm.c.orig Thu Nov 9 18:14:40 2006 +++ src/misc/vlm.c Tue Oct 31 18:39:28 2006 @@ -613,7 +613,8 @@ if( strcmp( ppsz_command[2], "play" ) && strcmp( ppsz_command[2], "stop" ) && strcmp( ppsz_command[2], "pause" ) && - strcmp( ppsz_command[2], "seek" ) ) + strcmp( ppsz_command[2], "seek" ) && + strcmp( ppsz_command[2], "msecseek" ) ) { i_index++; psz_instance = ppsz_command[2]; @@ -1274,6 +1275,23 @@ } } } + else if( !strcmp( psz_command, "msecseek" ) ) + { + double d_msec; + vlc_value_t val, current; + + if( psz_args ) + { + d_msec = i18n_atof( psz_args ); + val.i_time = (int64_t)(d_msec * 1000); + var_Get( p_instance->p_input, "length", &current ); + if( val.i_time >= 0 && val.i_time <= current.i_time ) + { + var_Set( p_instance->p_input, "time", val ); + return VLC_SUCCESS; + } + } + } else if( !strcmp( psz_command, "rewind" ) ) { float f_pos; @@ -2044,6 +2062,7 @@ MessageAddChild( "pause" ); MessageAddChild( "stop" ); MessageAddChild( "seek (percentage)" ); + MessageAddChild( "msecseek (time in milliseconds)" ); return message; }
0.8.6 patch

Code: Select all

--- src/misc/vlm.c.orig Thu Nov 9 18:26:51 2006 +++ src/misc/vlm.c Wed Nov 1 13:51:46 2006 @@ -615,7 +615,8 @@ if( strcmp( ppsz_command[2], "play" ) && strcmp( ppsz_command[2], "stop" ) && strcmp( ppsz_command[2], "pause" ) && - strcmp( ppsz_command[2], "seek" ) ) + strcmp( ppsz_command[2], "seek" ) && + strcmp( ppsz_command[2], "msecseek" ) ) { i_index++; psz_instance = ppsz_command[2]; @@ -1276,6 +1277,23 @@ } } } + else if( !strcmp( psz_command, "msecseek" ) ) + { + double d_msec; + vlc_value_t val, current; + + if( psz_args ) + { + d_msec = i18n_atof( psz_args ); + val.i_time = (int64_t)(d_msec * 1000); + var_Get( p_instance->p_input, "length", &current ); + if( val.i_time >= 0 && val.i_time <= current.i_time ) + { + var_Set( p_instance->p_input, "time", val ); + return VLC_SUCCESS; + } + } + } else if( !strcmp( psz_command, "stop" ) ) { TAB_REMOVE( media->i_instance, media->instance, p_instance ); @@ -2011,6 +2029,7 @@ MessageAddChild( "pause" ); MessageAddChild( "stop" ); MessageAddChild( "seek (percentage)" ); + MessageAddChild( "msecseek (time in milliseconds)" ); return message; }

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 10 Nov 2006 00:45

I'd be glad to apply that patch. Can you give me your real name so we can give you credit for the code ?
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

igorh
Blank Cone
Blank Cone
Posts: 14
Joined: 04 Oct 2006 23:45
Location: Massachusetts, USA

Postby igorh » 10 Nov 2006 01:08

Great. My real name is Igor Helman. Thanks for your help, Antoine.

-igor

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 10 Nov 2006 01:36

Hum, i just applied that patch (plus some other misc changes) to trunk but i think that i'll still change it some more.
like have

Code: Select all

control media seek 0.23 -> behaves like before (can't break previous behavior) control media seek +0.23 -> seek 23% forward control media seek -0.23 -> seek 23% backwards control media seek 123ms -> msecseek same with +/- control media seek 123s -> secseek
don't know if we need something to seek by minutes and hours too ... that will be easy to add if we do.
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 10 Nov 2006 02:03

Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

igorh
Blank Cone
Blank Cone
Posts: 14
Joined: 04 Oct 2006 23:45
Location: Massachusetts, USA

Postby igorh » 10 Nov 2006 03:45

Cool - that would work for me as well. I'll pull down the changes and test out the build. Thanks.

igorh
Blank Cone
Blank Cone
Posts: 14
Joined: 04 Oct 2006 23:45
Location: Massachusetts, USA

0.8.6 backport?

Postby igorh » 13 Nov 2006 22:03

Any way you can back-port this feature into 0.8.6? It seems like its pretty straightforward in terms of functionality and it would really help with my current project, as 0.8.6 seems more stable for our use than 0.9.0.

Thanks again,
-igor

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 19 Nov 2006 18:16

Sure, i'll backport that.
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

igorh
Blank Cone
Blank Cone
Posts: 14
Joined: 04 Oct 2006 23:45
Location: Massachusetts, USA

Postby igorh » 20 Nov 2006 17:56

Antoine, I rolled a patch for that change (17599) and the two previous ones to the vlm.c file (they were compiler warning fixes in 17227 and better syntax checking in 17596).

This would backport that "seek" functionality to 0.8.6 and fix a few warnings. If you can put that into the source, that would be great and I could start using the nightlies without having to roll a custom build.

Thanks again,
-igor

Code: Select all

--- src/misc/vlm.c.bak Mon Nov 20 10:49:47 2006 +++ src/misc/vlm.c Mon Nov 20 11:49:21 2006 @@ -51,12 +51,12 @@ /***************************************************************************** * Local prototypes. *****************************************************************************/ -static vlm_message_t *vlm_Show( vlm_t *, vlm_media_t *, vlm_schedule_t *, char * ); +static vlm_message_t *vlm_Show( vlm_t *, vlm_media_t *, vlm_schedule_t *, const char * ); static vlm_message_t *vlm_Help( vlm_t *, char * ); static vlm_media_instance_t *vlm_MediaInstanceSearch( vlm_t *, vlm_media_t *, const char * ); -static vlm_message_t *vlm_MessageNew( char *, const char *, ... ); +static vlm_message_t *vlm_MessageNew( const char *, const char *, ... ); static vlm_message_t *vlm_MessageAdd( vlm_message_t *, vlm_message_t * ); static vlm_schedule_t *vlm_ScheduleSearch( vlm_t *, const char * ); @@ -621,6 +621,12 @@ psz_instance = ppsz_command[2]; if( i_command < 4 ) goto syntax_error; + + if( strcmp( ppsz_command[3], "play" ) && + strcmp( ppsz_command[3], "stop" ) && + strcmp( ppsz_command[3], "pause" ) && + strcmp( ppsz_command[3], "seek" ) ) + goto syntax_error; } psz_command = ppsz_command[i_index]; @@ -1263,16 +1269,57 @@ if( !strcmp( psz_command, "seek" ) ) { vlc_value_t val; - float f_percentage; if( psz_args ) { - f_percentage = i18n_atof( psz_args ); - if( f_percentage >= 0.0 && f_percentage <= 100.0 ) - { - val.f_float = f_percentage / 100.0 ; - var_Set( p_instance->p_input, "position", val ); - return VLC_SUCCESS; + vlc_bool_t i_rel; + float f_value = i18n_atof( psz_args ); + if( psz_args[0] == '+' || psz_args[0] == '-' ) + i_rel = VLC_TRUE; + else + i_rel = VLC_FALSE; + if( strstr( psz_args, "ms" ) ) + { + /* milliseconds */ + int64_t i_msec = 1000 * (int64_t)atoi( psz_args ); + if( i_rel ) + { + var_SetTime( p_instance->p_input, "time-offset", i_msec ); + } + else if( i_msec >= 0 + && i_msec < var_GetTime( p_instance->p_input, "length" ) ) + { + var_SetTime( p_instance->p_input, "time", i_msec ); + } + } + else if( strchr( psz_args, 's' ) ) + { + /* seconds */ + int64_t i_sec = 1000000 * (int64_t)atoi( psz_args ); + if( i_rel ) + { + var_SetTime( p_instance->p_input, "time-offset", i_sec ); + } + else if( i_sec >= 0 + && i_sec < var_GetTime( p_instance->p_input, "length" ) ) + { + var_SetTime( p_instance->p_input, "time", i_sec ); + } + } + else + { + /* percentage */ + f_value /= 100.; + if( i_rel ) + { + float f_orig = var_GetFloat( p_instance->p_input, "position" ); + f_value += f_orig; + } + if( f_value >= 0.0 && f_value <= 1.0 ) + { + var_SetFloat( p_instance->p_input, "position", f_value ); + return VLC_SUCCESS; + } } } } @@ -1315,7 +1362,7 @@ /***************************************************************************** * Schedule handling *****************************************************************************/ -static int64_t vlm_Date() +static int64_t vlm_Date( void ) { #ifdef WIN32 struct timeb tm; @@ -1578,7 +1625,7 @@ /***************************************************************************** * Message handling functions *****************************************************************************/ -static vlm_message_t *vlm_MessageNew( char *psz_name, +static vlm_message_t *vlm_MessageNew( const char *psz_name, const char *psz_format, ... ) { vlm_message_t *p_message; @@ -1641,7 +1688,7 @@ * Misc utility functions *****************************************************************************/ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, - vlm_schedule_t *schedule, char *psz_filter ) + vlm_schedule_t *schedule, const char *psz_filter ) { if( media != NULL ) { @@ -2010,7 +2057,7 @@ MessageAddChild( "play" ); MessageAddChild( "pause" ); MessageAddChild( "stop" ); - MessageAddChild( "seek (percentage)" ); + MessageAddChild( "seek [+-](percentage) | [+-](seconds)s | [+-](milliseconds)ms" ); return message; }

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 21 Nov 2006 22:11

OK you win :) I'll apply it.
Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

dionoea
Cone Master
Cone Master
Posts: 5157
Joined: 03 Dec 2003 23:09
Location: Paris, France

Postby dionoea » 21 Nov 2006 22:15

Antoine Cellerier
dionoea
(Please do not use private messages for support questions)

igorh
Blank Cone
Blank Cone
Posts: 14
Joined: 04 Oct 2006 23:45
Location: Massachusetts, USA

Postby igorh » 21 Nov 2006 22:35

sweet!. thank you! looking forward to testing the nightlies.

igorh
Blank Cone
Blank Cone
Posts: 14
Joined: 04 Oct 2006 23:45
Location: Massachusetts, USA

bug in updating time.

Postby igorh » 11 Dec 2006 19:57

I just pulled down the 0.8.6 build and there seems to be a bug with this feature, where the time doesn't update after a seek until it reaches that initial time again (so that playing to 60 sec, then seeking to 30 sec will freeze the time display at 60 until the video playback passes 60 sec, then it will start updating again).. the video plays fine but without accurate timing information i can't update my display.

this is the same in 0.9.0. my mingw environment is broken at the moment so i can't test why calling var_Set made it work, whereas var_SetTime produces this behavior.. any chance of a fix?

Thanks again,
-igor

eclip5e
Blank Cone
Blank Cone
Posts: 13
Joined: 16 Oct 2006 21:02
Contact:

Postby eclip5e » 20 Dec 2006 18:31

Hi, I'm seeing time update problems with the VLM and seek to time control commands. (Works fine with seek to percentage).

This is a fresh install of the 0.8.6 release.

If i issue seek commands via the telnet or web VLM interface and specify a time previous to the current playback position (time A), the video successfully jumps to the specified seek time (time B), but the time that the VLM interface returns remains to be time A. Time also stops updating from time A, until playback from time B reaches time A. At this point, time continues to update as normal.

My guess is that the code to update the time checks to make sure the time has incremented past the last time, but after a jump, the update is blocked since it is less than the last time it has seen. The code path must be different for seek to time rather and seek to percent.


Return to “VLM”

Who is online

Users browsing this forum: No registered users and 6 guests