Python script for dual video streams
#1
Sad 
folks,

i am trying to write a simple python script that plays two video files - red.avi and green.avi. each of these video files are 5 minutes long. i want them to be played in this particular manner:

minute 1 of red.avi
minute 1 of green.avi
minute 2 of red.avi
minute 2 of green.avi
minute 3 of red.avi
minute 3 of green.avi
minute 4 of red.avi
minute 4 of green.avi
minute 5 of red.avi
minute 5 of green.avi

i was trying to use the logic below.
1. declare two instances of xbmc.player() - say, player_red and player_green.
2. player_red.play("red.avi")
time.sleep(oneminute)
player_red.pause()
player_green.play("green.avi")
time.sleep(oneminute)
for (i = 0; i < 4; i++)
player_green.pause() # pause and resume alternatively
player_red.pause() # resume and pause alternatively
time.sleep(oneminute)

however, this script only plays a few seconds of "red.avi" and then switches completely to "green.avi" with some pausing in between.

i tried to dig in a bit deeper and found that in namespace pyxbmc, player_play calls mediaplay with the filename, however player_pause calls mediapause without any argument. does this imply that a call to pause disregards the stream that is being played by the object on which pause is invoked, while play does take into account the stream? if so, why the disconnect?

could someone please help? :help:

thanks,
ranga
Reply
#2
why not splice the videos together on your pc?
Reply
#3
my requirement is such that i need to dynamically decide if i want to skip, say the third minute segment of the green file... another application that i am interested in is picture-in-picture...
Reply
#4
only one instance of mplayer can be run at a time.

replace pause with stop perhaps and on each load, immediately after do a seek to the required position. you'll also need to alter your pause length, as it won't take into account the length of time required to start mplayer + load the file etc. i'm not sure if python supports the reading of the current time in the movie that's playing, but if it does you could go into a loop and wait until the time hits 1 minute etc.

cheers,
jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
Exclamation 
hi jonathan,

thanks a lot for pointing out the issue. it is good to know that only one instance of mplayer can be running at a time.

a quick followup question would be if there is any other video player xbmc supports, of which i can declare an instance (i can convert one of the avi files to a different format, if needed)? ofcourse, this player will have to have python interface, since i do not have a xbmc compilation system setup and have access to only python scripting.

also, is it very hard to add support for multiple mplayer instances? are there architectural changes involved? have we decided to support a single instance because of performance issues? if it is not a big deal and can be done by one of you experienced xbmc guys in a day or two, maybe it'll take me a week to get the same done and it is worth for me to spend the time. it'll be a good way to get my hands dirty (always love that!Wink and will also be able to contribute to the project.

thanks very much,
ranga
Reply
#6
yeah, it's like that by design. we have limited resources (particularly ram) so having one player at a time is like that by design. also, in general there is little need for having to have 2 players about. picture in picture is not really feasible due to the doubling of required resources. with that said, it is technically possible to code it to allow 2 players, but it would require quite a bit of work, as the whole app is designed around the single player architecture.

cheers,
jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#7
thanks! is there any other video player that xbmc supports, like an independent quicktime player, of which i can declare an instance (i can convert one of the avi files to a different format, say quicktime, if needed)? ofcourse, this player will have to have python interface, since i do not have a xbmc compilation system setup and have access to only python scripting...
Reply
#8
no. there is only 1 player of any type runnable at the same time. and the only video player core is mplayer.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#9
is there a way to seek into a video using python? what about getting current playing time? this information would be incredibly useful for some of the scripts i'm working on, but hasn't been available. how hard would it be to add?

i could cobble something together that could estimate the playing time (by catching the "onplaybackstarted" event and saving the system time...), but it would be a lot uglier than just asking xbmc for the playtime.

there's nothing i could do fake seek time, though. i know xbmc allows it (you can type in a play time on the ir remote, right?), and it would be very nice to be able to send an int value from a python command that would do the same thing.

is this already in there, and just not in the python docs? or...if not, any chance we'll see it added soon? if not (to both of those), then your suggested solution (jmarshall) doesn't really work.

i'm very interested because i'm working on a mostly unrelated project that hinges on exactly the same issues ranganathrao is asking about.
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply

Logout Mark Read Team Forum Stats Members Help
Python script for dual video streams0