Mercurial > code > home > repos > light9
changeset 526:a60a73463ef0
vidref now pretty much saves and loads frames
Ignore-this: 80fa2ddda0ae744071cd43b9a16fdc18
author | drewp@bigasterisk.com |
---|---|
date | Wed, 09 Jun 2010 07:05:40 +0000 |
parents | d3f8333bc142 |
children | a3bad700f2a8 |
files | light9/networking.py light9/showconfig.py light9/vidref/main.py light9/vidref/vidref.glade |
diffstat | 4 files changed, 74 insertions(+), 70 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/networking.py Wed Jun 09 05:35:54 2010 +0000 +++ b/light9/networking.py Wed Jun 09 07:05:40 2010 +0000 @@ -11,8 +11,12 @@ def dmxServerPort(): return 8030 -def musicUrl(): - return "http://score:%s" % musicPort() +def musicUrl(api='xmlrpc'): + site = "http://dash:%s/" % musicPort() + if api == 'rest': + return site + "api/" + else: + return site + "RPC2" def musicPort(): return 8040
--- a/light9/showconfig.py Wed Jun 09 05:35:54 2010 +0000 +++ b/light9/showconfig.py Wed Jun 09 07:05:40 2010 +0000 @@ -41,7 +41,8 @@ including trailing slash""" mpdHome = None - for mpdConfFilename in ["~/.mpdconf", "/etc/mpd.conf"]: + for mpdConfFilename in ["/my/dl/modified/mpd/src/mpdconf-testing", + "~/.mpdconf", "/etc/mpd.conf"]: try: mpdConfFile = open(path.expanduser(mpdConfFilename)) except IOError: @@ -76,7 +77,10 @@ def songOnDisk(song): """given a song URI, where's the on-disk file that mpd would read?""" graph = getGraph() - songFullPath = path.join(findMpdHome(), graph.value(song, L9['showPath'])) + showPath = graph.value(song, L9['showPath']) + if not showPath: + raise ValueError("no mpd path found for subject=%r" % song) + songFullPath = path.join(findMpdHome(), showPath) return songFullPath def songFilenameFromURI(uri):
--- a/light9/vidref/main.py Wed Jun 09 05:35:54 2010 +0000 +++ b/light9/vidref/main.py Wed Jun 09 07:05:40 2010 +0000 @@ -22,23 +22,7 @@ logging.getLogger().setLevel(logging.WARN) #restkit.set_logging(logging.WARN) -print jsonlib.loads(restkit.Resource(networking.musicUrl()).get("api/position").body, use_float=True) - -import StringIO -# gtk.gdk.pixbuf_new_from_data(img.tostring() seems like it would be better -# http://www.daa.com.au/pipermail/pygtk/2003-June/005268.html -def Image_to_GdkPixbuf (image): - file = StringIO.StringIO () - image.save (file, 'ppm') - contents = file.getvalue() - file.close () - loader = gtk.gdk.PixbufLoader ('pnm') - loader.write (contents, len (contents)) - pixbuf = loader.get_pixbuf () - loader.close () - return pixbuf - -existingDir = "/tmp/vidref/play-light9.bigasterisk.com_show_dance2010_song7-1276057905" +existingDir = "/tmp/vidref/play-light9.bigasterisk.com_show_dance2010_song7-1276065914" existingFrames = sorted([Decimal(f.split('.jpg')[0]) for f in os.listdir(existingDir)]) @@ -57,7 +41,7 @@ self.sinkpad.set_chain_function(self.chainfunc) self.lastTime = 0 - self.musicResource = restkit.Resource(networking.musicUrl()) + self.musicResource = restkit.Resource(networking.musicUrl(api='rest')) self.imagesToSave = Queue() self.startBackgroundImageSaver(self.imagesToSave) @@ -66,8 +50,8 @@ """do image saves in another thread to not block gst""" def imageSaver(): while True: - position, img = imagesToSave.get() - self.saveImg(position, img) + args = imagesToSave.get() + self.saveImg(*args) imagesToSave.task_done() t = Thread(target=imageSaver) @@ -79,18 +63,16 @@ self.info("%s timestamp(buffer):%d" % (pad, buffer.timestamp)) try: - position = jsonlib.loads(self.musicResource.get("api/position").body, + position = jsonlib.loads(self.musicResource.get("position").body, use_float=True) if not position['song']: return gst.FLOW_OK cap = buffer.caps[0] - #img = Image.fromstring('RGB', (cap['width'], cap['height']), - # buffer.data) - #self.imagesToSave.put((position, img)) - #pixbuf = Image_to_GdkPixbuf(img) - #otherPic.set_from_pixbuf(pixbuf) + img = Image.fromstring('RGB', (cap['width'], cap['height']), + buffer.data) + self.imagesToSave.put((position, img, buffer.timestamp)) except: traceback.print_exc() @@ -101,7 +83,7 @@ return gst.FLOW_OK - def saveImg(self, position, img): + def saveImg(self, position, img, bufferTimestamp): outDir = "/tmp/vidref/play-%s-%d" % ( position['song'].split('://')[-1].replace('/','_'), position['started']) @@ -117,17 +99,19 @@ img.save(outFilename) now = time.time() - print "wrote %s delay of %.2fms" % (outFilename, - (now - self.lastTime) * 1000) + print "wrote %s delay of %.2fms %s" % (outFilename, + (now - self.lastTime) * 1000, + bufferTimestamp) self.lastTime = now def updateOtherFrames(self, position): - inPic = self.findClosestFrame(position['t']+.15) - print "load", inPic + inPic = self.findClosestFrame(position['t']+.2) + #print "load", inPic with gtk.gdk.lock: otherPic.set_from_file(inPic) - otherPic.queue_draw_area(0,0,320,240) - otherPic.get_window().process_updates(True) + if 0: + otherPic.queue_draw_area(0,0,320,240) + otherPic.get_window().process_updates(True) def findClosestFrame(self, t): i = bisect_left(existingFrames, Decimal(str(t))) @@ -158,7 +142,7 @@ ## source = makeElem("v4l2src", "vsource") ## source.set_property("device", "/dev/video0") - dv = "dv1394src ! dvdemux ! dvdec ! videoscale ! video/x-raw-yuv,width=320" + dv = "dv1394src ! dvdemux ! dvdec ! videoscale ! video/x-raw-yuv,width=320,height=240;video/x-raw-rgb,width=320,height=240 ! queue name=vid" v4l = "v4l2src device=/dev/video0 ! hqdn3d name=vid" pipeline = gst.parse_launch(dv)
--- a/light9/vidref/vidref.glade Wed Jun 09 05:35:54 2010 +0000 +++ b/light9/vidref/vidref.glade Wed Jun 09 07:05:40 2010 +0000 @@ -9,46 +9,25 @@ <object class="GtkFixed" id="fixed1"> <property name="visible">True</property> <child> - <object class="GtkLabel" id="label1"> - <property name="width_request">85</property> - <property name="height_request">20</property> - <property name="visible">True</property> - <property name="yalign">0.47999998927116394</property> - <property name="label" translatable="yes">Live view</property> - </object> - <packing> - <property name="x">5</property> - <property name="y">16</property> - </packing> - </child> - <child> - <object class="GtkImage" id="liveVideo"> - <property name="width_request">474</property> - <property name="height_request">291</property> - <property name="visible">True</property> - </object> - <packing> - <property name="x">6</property> - <property name="y">40</property> - </packing> - </child> - <child> <object class="GtkFrame" id="frame1"> - <property name="width_request">338</property> - <property name="height_request">269</property> + <property name="width_request">336</property> + <property name="height_request">277</property> <property name="visible">True</property> <property name="label_xalign">0</property> <property name="shadow_type">out</property> <child> - <object class="GtkAlignment" id="alignment1"> + <object class="GtkFixed" id="fixed2"> <property name="visible">True</property> - <property name="left_padding">12</property> <child> <object class="GtkDrawingArea" id="vid3"> - <property name="width_request">100</property> - <property name="height_request">80</property> + <property name="width_request">320</property> + <property name="height_request">240</property> <property name="visible">True</property> </object> + <packing> + <property name="x">7</property> + <property name="y">8</property> + </packing> </child> </object> </child> @@ -61,8 +40,41 @@ </child> </object> <packing> - <property name="x">496</property> - <property name="y">41</property> + <property name="x">15</property> + <property name="y">10</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame2"> + <property name="width_request">336</property> + <property name="height_request">259</property> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="shadow_type">out</property> + <child> + <object class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="left_padding">12</property> + <child> + <object class="GtkImage" id="liveVideo"> + <property name="width_request">320</property> + <property name="height_request">240</property> + <property name="visible">True</property> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Playback 1</b></property> + <property name="use_markup">True</property> + </object> + </child> + </object> + <packing> + <property name="x">373</property> + <property name="y">23</property> </packing> </child> </object>