Lua for stream syncing?

Discuss your Lua playlist, album art and interface scripts.
buzz_lightyear
New Cone
New Cone
Posts: 8
Joined: 29 Jun 2010 15:31

Lua for stream syncing?

Postby buzz_lightyear » 30 Jun 2010 10:17

Hi all,
i am trying to solve stream syncing problem and would like to ask for some help or advice, please...

The setup

Code: Select all

new high_01 broadcast enabled loop setup high_01 input "black_sheep_4_3.mpg_HIGH.ts" setup high_01 input "Lost_in_Space_4_3.mpg_HIGH.ts" setup high_01 output #std{access=udp,mux=ts,dst=239.255.11.1:10003} # new mid_01 broadcast enabled loop setup mid_01 input "black_sheep_4_3.mpg_MID.ts" setup mid_01 input "Lost_in_Space_4_3.mpg_MID.ts" setup mid_01 output #std{access=udp,mux=ts,dst=239.255.11.1:10002} # new low_01 broadcast enabled loop setup low_01 input "black_sheep_4_3.mpg_LOW.ts" setup low_01 input "Lost_in_Space_4_3.mpg_LOW.ts" setup low_01 output #std{access=udp,mux=ts,dst=239.255.11.1:10001} # control high_01 play control mid_01 play control low_01 play ###################
I am streaming 3 output streams with same content (same inputs), but with different resolution and bitrate in each output.

The problem
After a while, those 3 output streams will run out of sync between them, so when a bitrate switch is needed (actually switch to different output stream), on end device i see different scene.

The temporary solution
At the moment i have a "solution" for this, which is a perl script connecting to vlm telnet interface, getting the position from the "show" command in regular intervals and if the sync drift between those three outputs is bigger than 2%, it will "seek" two lower bitrate streams to the high bitrate stream position.

This works so far, but i'd like to have some better solution.

The question
Would it be possible to solve this with LUA scripting?
In best case, i'd like to be able to continuously adjust the video playback rate, until all three positions will match.
If that is not possible, i'd like to be able to use LUA, to get positions of all three streams and adjust as i do with perl (described above).

Many thanxs for advice or help
buzz

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: Lua for stream syncing?

Postby ivoire » 05 Jul 2010 14:28

I think you can do this by modifiying the telnet lua interface to ad a command that synchronize the streams on demand.

buzz_lightyear
New Cone
New Cone
Posts: 8
Joined: 29 Jun 2010 15:31

Re: Lua for stream syncing?

Postby buzz_lightyear » 06 Jul 2010 15:57

I think you can do this by modifiying the telnet lua interface to ad a command that synchronize the streams on demand.
Hi ivoire,
thanx for answer... yes, that is very right. ;)
The question is, how exactly can i do that?
By parsing the "show" output? That one i do in perl already.

My idea is, that (if possible) i'd like to use vlc.vlm object not just to send "show" command and retreive/parse the response, but i'd like to programatically access media, and it's properties.

thanx for help
buzz

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: Lua for stream syncing?

Postby ivoire » 07 Jul 2010 10:02

In the telnet.lua script you can add a command that will loop forever (or for an given number of loops) and ask the parameters from the vlm object and synchronize the streams.
The only difference is the fact that with a custom command in the telnet.lua file you do not have to parse the output as you are "inside" the interface. Every information are acessible through variables and functions this way.
Am I clear or not ? (not sure :))

buzz_lightyear
New Cone
New Cone
Posts: 8
Joined: 29 Jun 2010 15:31

Re: Lua for stream syncing?

Postby buzz_lightyear » 07 Jul 2010 13:06

In the telnet.lua script you can add a command that will loop forever (or for an given number of loops) and ask the parameters from the vlm object and synchronize the streams.
The only difference is the fact that with a custom command in the telnet.lua file you do not have to parse the output as you are "inside" the interface. Every information are acessible through variables and functions this way.
Am I clear or not ? (not sure :))
hi ivoire,
Great! that is exactly what i am looking for. ;)
However, is there a list of all variables and functions, which i can access? That is the part, that i am actually missing.

once again, many thanxs for your kind help
buzz

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: Lua for stream syncing?

Postby ivoire » 07 Jul 2010 13:16

http://git.videolan.org/?p=vlc.git;a=bl ... c6;hb=HEAD
Lis most of the function (if some are missing please say so !)

buzz_lightyear
New Cone
New Cone
Posts: 8
Joined: 29 Jun 2010 15:31

Re: Lua for stream syncing?

Postby buzz_lightyear » 07 Jul 2010 14:36

thank you...
Looking at the list, is this the whole vlm object access?

Code: Select all

395 VLM 396 --- 397 vlm(): Instanciate a VLM object. 398 399 v = vlc.vlm() 400 v:execute_command( "new test broadcast" ) -- execute given VLM command 401 402 Note: if the VLM object is deleted and you were the last person to hold 403 a reference to it, all VLM items will be deleted.
isn't there something like:

Code: Select all

v = vlc.vlm() v:new,broadcast("test") v:setup.test.input("blabla_my_input") v:setup.test.output("#std{access=udp,mux=ts,dst=239.255.11.1:10002}") v:control.test.play()
thanx
buzz

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: Lua for stream syncing?

Postby ivoire » 07 Jul 2010 14:51

No you can only use v:execute_command(cmd).
Might be adding something to do v:setup.test.input() is a good idea but not for the moment.
If you want this feature, fill a ticket in the trac (trac.videolan.org)

buzz_lightyear
New Cone
New Cone
Posts: 8
Joined: 29 Jun 2010 15:31

Re: Lua for stream syncing?

Postby buzz_lightyear » 07 Jul 2010 15:44

No you can only use v:execute_command(cmd).
Might be adding something to do v:setup.test.input() is a good idea but not for the moment.
If you want this feature, fill a ticket in the trac (trac.videolan.org)
yes, that would be a great addition to vlc, that you can "natively" control all the vlm stuff via lua.

...if you would add those features (on some nice day in the future :) ), which source files would you edit?
Maybe i can have a look at it meanwhile...

thanx
buzz

ivoire
Cone that earned his stripes
Cone that earned his stripes
Posts: 413
Joined: 20 Aug 2008 11:29
VLC version: trunk
Operating System: linux (debian sid)
Contact:

Re: Lua for stream syncing?

Postby ivoire » 07 Jul 2010 15:48

The vlc function are added in lua in modules/misc/lua/libs/ files. In this case, the right file is modules/misc/lua/libs/vlm.c

If you add some feature do not forget to send us a patch, so we can integrate it!

buzz_lightyear
New Cone
New Cone
Posts: 8
Joined: 29 Jun 2010 15:31

Re: Lua for stream syncing?

Postby buzz_lightyear » 07 Jul 2010 16:21

thanx & have a nice day
buzz


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 14 guests