do_cleanup()
+def _start_movie_thumbnailer():
+ import mediafiles
+
+ def do_next_movie_thumbail():
+ ioloop = tornado.ioloop.IOLoop.instance()
+ if ioloop._stopped:
+ return
+
+ try:
+ mediafiles.make_next_movie_preview()
+
+ except Exception as e:
+ logging.error('failed to make movie thumbnail: %(msg)s' % {
+ 'msg': unicode(e)})
+
+ ioloop.add_timeout(datetime.timedelta(seconds=settings.MJPG_CLIENT_TIMEOUT), do_next_movie_thumbail)
+
+ do_next_movie_thumbail()
+
+
if __name__ == '__main__':
_configure_settings()
_configure_signals()
_start_motion()
_start_cleanup()
+ _start_movie_thumbnailer()
_start_server()
'path': full_path, 'offs': offs}
try:
- subprocess.check_call(cmd, shell=True)
+ subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
logging.error('failed to create movie preview for %(path)s: %(msg)s' % {
return full_path + '.thumb'
+def make_next_movie_preview():
+ logging.debug('making preview for the next movie...')
+
+ for camera_id in config.get_camera_ids():
+ camera_config = config.get_camera(camera_id)
+ if camera_config.get('@proto') != 'v4l2':
+ continue
+
+ target_dir = camera_config['target_dir']
+
+ for full_path in _list_media_files(target_dir, _MOVIE_EXTS):
+ # TODO files listed here may not belong to the given camera
+
+ if os.path.exists(full_path + '.thumb'):
+ continue
+
+ logging.debug('found a movie without preview: %(path)s' % {
+ 'path': full_path})
+
+ make_movie_preview(camera_config, full_path)
+
+ break
+
+ else:
+ logging.debug('all movies have preview')
+
+
def list_media(camera_config, media_type):
target_dir = camera_config.get('target_dir')