# HG changeset patch # User drewp@bigasterisk.com # Date 2013-06-13 01:44:05 # Node ID 3aae87f6777a2659b673c07a7793754a284cf344 # Parent dd896321faee261f186975d9e2306f86836a19a8 vidref grab images for snapshots even if a song is not playing Ignore-this: 81b9b8c86a6326be3dd5a7d900f16a1b diff --git a/light9/vidref/musictime.py b/light9/vidref/musictime.py --- a/light9/vidref/musictime.py +++ b/light9/vidref/musictime.py @@ -31,6 +31,8 @@ class MusicTime(object): 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} diff --git a/light9/vidref/videorecorder.py b/light9/vidref/videorecorder.py --- a/light9/vidref/videorecorder.py +++ b/light9/vidref/videorecorder.py @@ -120,6 +120,14 @@ class VideoRecordSink(gst.Element): 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 @@ class VideoRecordSink(gst.Element): 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 @@ class VideoRecordSink(gst.Element): 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'])