Where is the "time" variable set ?

This forum is about all development around libVLC.
Vicne
Blank Cone
Blank Cone
Posts: 40
Joined: 28 Feb 2010 22:11

Where is the "time" variable set ?

Postby Vicne » 16 Jun 2010 20:17

Hi, all,

[First, sorry if this is off-topic, it's a general VLC development question, not specifically linked to libVLC, but I have no idea where else to post it...]

I intend to use VLC as a player in a professional video environment and, like many, I need a way to display the actual timecode embedded in the video files instead of a zero-based frame counter.
I successfully expanded the marquee functionality so that it can be given an offset that gets added to the actual video counter upon display. By getting the start TC from the video file beforehand, I can then display it in conveniently as an overlay on the picture (code available if anyone is interested).
Now the problem is that I would like to include decimals (or number of frames), but it seems the counter is only updated once per second. I would like to improve its precision but I cannot find the code that sets its value.
The counter I'm talking about is the one used by the $T marquee as follows.
int64_t i_time = var_GetTime( p_input, "time" )

Any hint or pointer would be greatly appreciated.

Best regards,

Vicne

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Where is the "time" variable set ?

Postby Jean-Baptiste Kempf » 16 Jun 2010 21:26

src/input/event.c
src/input/control.c
src/input/var.c
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

Rémi Denis-Courmont
Developer
Developer
Posts: 15258
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Where is the "time" variable set ?

Postby Rémi Denis-Courmont » 17 Jun 2010 03:38

It's str_format_meta() you're probably looking for (src/text/strings.c).
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Vicne
Blank Cone
Blank Cone
Posts: 40
Joined: 28 Feb 2010 22:11

Re: Where is the "time" variable set ?

Postby Vicne » 17 Jun 2010 09:03

It's str_format_meta() you're probably looking for (src/text/strings.c).
Hi, Rémi, and thanks for the answer.

str_format_meta() is the place I already successfully modified to add the offset but it seems that the call :

Code: Select all

int64_t i_time = var_GetTime( p_input, "time" );
always returns a value in integer seconds ( last 6 digits of i_time are always 000000).

My target now is to see how this value is set and try to increase its precision (I work with PAL so I'd need at least a 40ms precision), which might also need an increase of the rate at which the "set" is called.

Best regards,

Vicne

Vicne
Blank Cone
Blank Cone
Posts: 40
Joined: 28 Feb 2010 22:11

Re: Where is the "time" variable set ?

Postby Vicne » 17 Jun 2010 11:05

Hi, j-b,

Thanks for the pointers. I looked at the 3 sources you referred to.

The way I see it :
src/input/var.c contains init code and declaration of the PositionCallback
src/input/event.c contains the code called when an "event" happens (don't really know what the "event" is in this context)
src/input/control.c contains the code called when user seeks through the video

Am I right assuming that when the video "just plays", that's the callback (defined var.c) that gets called to update the time as it passes ?

Best regards,

Vicne

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Where is the "time" variable set ?

Postby Jean-Baptiste Kempf » 17 Jun 2010 12:25

I believe the var_Set are the one you are looking at, and the modules/demux/ GET_TIME
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

Matthijs
New Cone
New Cone
Posts: 1
Joined: 23 Jun 2010 13:26

Re: Where is the "time" variable set ?

Postby Matthijs » 23 Jun 2010 13:37

Dear Vicne,

For some research I am doing in the orthopaedics dept. here in the hospital I am using 3D-accelerometers. Now I am trying to distinguish the dynamic from the static part of the signal (static being the sensor orientation vs. earth's gravity). For this I made some recordings using a high-speed camera, but I run into the same problem as you, that the time is displayed only with 1s accuracy. If you find a solution for this could you let me know? In addition I am very interested in your code to print the time on the videoframes.

Thanks in advance for your trouble and time,
Matthijs

Vicne
Blank Cone
Blank Cone
Posts: 40
Joined: 28 Feb 2010 22:11

Re: Where is the "time" variable set ?

Postby Vicne » 23 Jun 2010 20:41

[...]I run into the same problem as you, that the time is displayed only with 1s accuracy. If you find a solution for this could you let me know? In addition I am very interested in your code to print the time on the videoframes.
Hi, Matthijs,

Unfortunately, I haven't had time to dig any further :-(. My C experience was only 10 years ago but that's already long and maybe VLC is a too serious beast for me ;-)

As for the display time, I guess you know that printing a "counter" starting at 00:00:00 is built in using the marquee overlay with the $T parameter.
My modification was to implement a way to add an offset to this counter so that base time can be for example 10:00 AM. To do this, the only change is in src/text/strings.c , as follows :
In the big switch/case of function str_format_meta(), I added the following code just before the "case 'T':" line :

Code: Select all

case 'M': if( p_input && (d + 8 < i_size)) { // parse the HH:MM:SS string following %M int hour, minute, second; if ( sscanf( s + 1, "%2d:%2d:%2d", &hour, &minute, &second ) == 3 ) { int64_t i_time = var_GetTime( p_input, "time" ) + 3600000000 * hour + 60000000 * minute + 1000000 * second; snprintf( buf, 10, "%02d:%02d:%02d", (int)( i_time / ( 3600000000 ) ), (int)( ( i_time / ( 60000000 ) ) % 60 ), (int)( ( i_time / 1000000 ) % 60 ) ); } else { snprintf( buf, 10, "#FMTERR#"); } memcpy ( s + 1, buf, 8 ); } else { snprintf( buf, 10, b_empty_if_na ? "" : "--:--:--" ); INSERT_STRING_NO_FREE( buf ); } break;
To use it, first, I advise you check that the $T marquee works as expected and counts from 00:00:00.
Then, replace $T by $M<offset>, where <offset> is the time offset to be added to the frame counter, in the form HH:MM:SS

If you want to pass it as command line option, you can start VLC with something like :

Code: Select all

vlc.exe --sub-filter "marq{marquee=$M10:00:00,position=6}" video.mpg
That's not much in return for the community, but I'm happy if it can help someone.

(Note : I chose 'M' for no real reason except that all other letters I was thinking of were already taken :-))

Best regards,

Vicne

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Where is the "time" variable set ?

Postby Jean-Baptiste Kempf » 24 Jun 2010 09:15

Patches should be sent to vlc-devel.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 21 guests