Changeset - 3aae87f6777a
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 12 years ago 2013-06-13 01:44:05
drewp@bigasterisk.com
vidref grab images for snapshots even if a song is not playing
Ignore-this: 81b9b8c86a6326be3dd5a7d900f16a1b
2 files changed with 16 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/vidref/musictime.py
Show inline comments
 
@@ -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}
light9/vidref/videorecorder.py
Show inline comments
 
@@ -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'])
0 comments (0 inline, 0 general)