Dear VLC'ers,
I am using the VLC python plugin and I'm having hard time in trying to display several recorded video streams in sync.
In python, I am creating several vlc instances, each one of them having their own media player, i.e:
******
vlci=vlc.Instance(st) # here st has the options given to the vlc instance (++)
player=vlci.media_player_new()
media=vlci.media_new(unicode(filename))
player.set_media(media)
******
The input media I am playing is an RTSP stream and I am performing the recording, by giving the following output option (++) to the "vlc" instance:
******
--sout=#duplicate{dst=std{access=file,mux=ts,dst='FILENAME'}} --sout-file-overwrite
******
.. where FILENAME is the name of the recorded stream (here either "stream1.avi", "stream2.avi" or "stream3.avi").
The three separate "vlci" instances each record a stream. The first two instances record the same camera, while the third one records a camera that has a higher bitrate. Finally I get three files:
******
> du -h *
2,3M stream1.avi
2,3M stream2.avi
60M stream3.avi
******
Next, I do a playback for these three streams simultaneously. During each second, I poll the position from the "player" instances of each vlc instance, i.e.:
player.get_position()
I get the following positions:
stream1, stream2, stream3
0.43595999479293823, 0.43168333172798157, 0.40312349796295166
0.4588924050331116, 0.4605380892753601, 0.4215429127216339
0.4695454239845276, 0.46996667981147766, 0.43995019793510437
Positions of streams 1 & 2 are practically the same (deviation less than one percent), as expected, while position of stream 3 lags behind.
As player.get_position() gives the fraction of the total time, then, for a video having the length of 1 minute, there will be a lag of ~ 1 second, while video of 30 minutes produces a lag of ~ 36 seconds ..!
How can I get the streams in sync?
When playing, I passed the vlc instance the following argument (++):
******
"--clock-synchro 1 --clock-jitter 5000"
******
.. but that did not work at all. Outside python, I tried to play around with:
******
cvlc stream1.avi --network-synchronisation --netsync-master -vvv
cvlc stream1.avi --network-synchronisation --netsync-master-ip 192.168.1.33 -vvv
******
.. and launching them simultaneously from different terminals (I start the "slave" first), but that did not work either. Both tell me:
[0x852168] netsync interface error: InputEvent DEAD
What is the best way to get the streams in sync in python?
Kind Regards,
Sampsa