Mercurial > code > home > repos > light9
changeset 943:3aae87f6777a
vidref grab images for snapshots even if a song is not playing
Ignore-this: 81b9b8c86a6326be3dd5a7d900f16a1b
author | drewp@bigasterisk.com |
---|---|
date | Thu, 13 Jun 2013 01:44:05 +0000 |
parents | dd896321faee |
children | 3b3cc5f98a03 |
files | light9/vidref/musictime.py light9/vidref/videorecorder.py |
diffstat | 2 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/vidref/musictime.py Thu Jun 13 01:31:16 2013 +0000 +++ b/light9/vidref/musictime.py Thu Jun 13 01:44:05 2013 +0000 @@ -31,6 +31,8 @@ def getLatest(self): """ dict with 't' and 'song', etc. + + Note that this may be called in a gst camera capture thread. """ if not hasattr(self, 'position'): return {'t' : 0, 'song' : None}
--- a/light9/vidref/videorecorder.py Thu Jun 13 01:31:16 2013 +0000 +++ b/light9/vidref/videorecorder.py Thu Jun 13 01:44:05 2013 +0000 @@ -120,6 +120,14 @@ args = imagesToSave.get() self.saveImg(*args) imagesToSave.task_done() + + # this is not an ideal place for snapshotRequests + # since imagesToSave is allowed to get backed up with + # image writes, yet we would still want the next new + # image to be used for the snapshot. chainfunc should + # put snapshot images in a separate-but-similar queue + # to imagesToSave, and then another watcher could use + # those to satisfy snapshot requests try: req = self.snapshotRequests.get(block=False) except Empty: @@ -135,9 +143,8 @@ def chainfunc(self, pad, buffer): position = self.musicTime.getLatest() - if not position['song']: - print "no song" # todo: this prints too much when the player has no song - return gst.FLOW_OK + # if music is not playing and there's no pending snapshot + # request, we could skip the image conversions here. try: cap = buffer.caps[0] @@ -151,6 +158,10 @@ return gst.FLOW_OK def saveImg(self, position, img, bufferTimestamp): + if not position['song']: + print "no song" + return + t1 = time.time() outDir = takeDir(songDir(position['song']), position['started']) outFilename = "%s/%08.03f.jpg" % (outDir, position['t'])