Add the option to change timelapse fps
This commit is contained in:
parent
f0a71acf98
commit
f5ece9b5b4
7 changed files with 46 additions and 12 deletions
|
|
@ -30,9 +30,11 @@ def getTimelapseData():
|
|||
if timelapse is not None and isinstance(timelapse, octoprint.timelapse.ZTimelapse):
|
||||
config["type"] = "zchange"
|
||||
config["postRoll"] = timelapse.postRoll()
|
||||
config["fps"] = timelapse.fps()
|
||||
elif timelapse is not None and isinstance(timelapse, octoprint.timelapse.TimedTimelapse):
|
||||
config["type"] = "timed"
|
||||
config["postRoll"] = timelapse.postRoll()
|
||||
config["fps"] = timelapse.fps()
|
||||
config.update({
|
||||
"interval": timelapse.interval()
|
||||
})
|
||||
|
|
@ -70,6 +72,7 @@ def setTimelapseConfig():
|
|||
config = {
|
||||
"type": request.values["type"],
|
||||
"postRoll": 0,
|
||||
"fps": 25,
|
||||
"options": {}
|
||||
}
|
||||
|
||||
|
|
@ -80,6 +83,12 @@ def setTimelapseConfig():
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
if "fps" in request.values:
|
||||
try:
|
||||
config["fps"] = int(request.values["fps"])
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if "interval" in request.values:
|
||||
interval = 10
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ default_settings = {
|
|||
"timelapse": {
|
||||
"type": "off",
|
||||
"options": {},
|
||||
"postRoll": 0
|
||||
"postRoll": 0,
|
||||
"fps": 25
|
||||
}
|
||||
},
|
||||
"gcodeViewer": {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -7,6 +7,7 @@ $(function() {
|
|||
self.timelapseType = ko.observable(undefined);
|
||||
self.timelapseTimedInterval = ko.observable(undefined);
|
||||
self.timelapsePostRoll = ko.observable(undefined);
|
||||
self.timelapseFps = ko.observable(undefined);
|
||||
|
||||
self.persist = ko.observable(false);
|
||||
self.isDirty = ko.observable(false);
|
||||
|
|
@ -42,6 +43,9 @@ $(function() {
|
|||
self.timelapsePostRoll.subscribe(function(newValue) {
|
||||
self.isDirty(true);
|
||||
});
|
||||
self.timelapseFps.subscribe(function(newValue) {
|
||||
self.isDirty(true);
|
||||
});
|
||||
|
||||
// initialize list helper
|
||||
self.listHelper = new ItemListHelper(
|
||||
|
|
@ -107,6 +111,12 @@ $(function() {
|
|||
self.timelapsePostRoll(undefined);
|
||||
}
|
||||
|
||||
if (config.fps != undefined && config.fps >= 0) {
|
||||
self.timelapseFps(config.fps);
|
||||
} else {
|
||||
self.timelapseFps(undefined);
|
||||
}
|
||||
|
||||
self.persist(false);
|
||||
self.isDirty(false);
|
||||
};
|
||||
|
|
@ -142,6 +152,7 @@ $(function() {
|
|||
var payload = {
|
||||
"type": self.timelapseType(),
|
||||
"postRoll": self.timelapsePostRoll(),
|
||||
"fps": self.timelapseFps(),
|
||||
"save": self.persist()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ table {
|
|||
}
|
||||
|
||||
#temp_newTemp, #temp_newBedTemp, #speed_innerWall, #speed_outerWall, #speed_fill, #speed_support,
|
||||
#webcam_timelapse_interval, #webcam_timelapse_postRoll {
|
||||
#webcam_timelapse_interval, #webcam_timelapse_postRoll, #webcam_timelapse_fps {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<label for="webcam_timelapse_fps">{{ _('Timelapse fps') }}</label>
|
||||
<div class="input-append">
|
||||
<input type="text" class="input-mini" id="webcam_timelapse_fps" data-bind="value: timelapseFps, valueUpdate: 'afterkeydown', enable: isOperational() && !isPrinting() && loginState.isUser() && timelapseTypeSelected()">
|
||||
<span class="add-on">{{ _('fps') }}</span>
|
||||
</div>
|
||||
|
||||
<div data-bind="visible: loginState.isAdmin">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: persist"> {{ _('Save as default') }}
|
||||
|
|
|
|||
|
|
@ -79,15 +79,19 @@ def configureTimelapse(config=None, persist=False):
|
|||
if "postRoll" in config:
|
||||
postRoll = config["postRoll"]
|
||||
|
||||
fps = 25
|
||||
if "fps" in config:
|
||||
fps = config["fps"]
|
||||
|
||||
if type is None or "off" == type:
|
||||
current = None
|
||||
elif "zchange" == type:
|
||||
current = ZTimelapse(postRoll=postRoll)
|
||||
current = ZTimelapse(postRoll=postRoll, fps=fps)
|
||||
elif "timed" == type:
|
||||
interval = 10
|
||||
if "options" in config and "interval" in config["options"]:
|
||||
interval = config["options"]["interval"]
|
||||
current = TimedTimelapse(postRoll=postRoll, interval=interval)
|
||||
current = TimedTimelapse(postRoll=postRoll, interval=interval, fps=fps)
|
||||
|
||||
notifyCallbacks(current)
|
||||
|
||||
|
|
@ -97,7 +101,7 @@ def configureTimelapse(config=None, persist=False):
|
|||
|
||||
|
||||
class Timelapse(object):
|
||||
def __init__(self, postRoll=0):
|
||||
def __init__(self, postRoll=0, fps=25):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
self._imageNumber = None
|
||||
self._inTimelapse = False
|
||||
|
|
@ -111,7 +115,7 @@ class Timelapse(object):
|
|||
self._movieDir = settings().getBaseFolder("timelapse")
|
||||
self._snapshotUrl = settings().get(["webcam", "snapshot"])
|
||||
|
||||
self._fps = 25
|
||||
self._fps = fps
|
||||
|
||||
self._renderThread = None
|
||||
self._captureMutex = threading.Lock()
|
||||
|
|
@ -127,6 +131,9 @@ class Timelapse(object):
|
|||
def postRoll(self):
|
||||
return self._postRoll
|
||||
|
||||
def fps(self):
|
||||
return self._fps
|
||||
|
||||
def unload(self):
|
||||
if self._inTimelapse:
|
||||
self.stopTimelapse(doCreateMovie=False)
|
||||
|
|
@ -267,7 +274,7 @@ class Timelapse(object):
|
|||
|
||||
# prepare ffmpeg command
|
||||
command = [
|
||||
ffmpeg, '-loglevel', 'error', '-i', input, '-vcodec', 'mpeg2video', '-pix_fmt', 'yuv420p', '-r', str(self._fps), '-y', '-b:v', bitrate,
|
||||
ffmpeg, '-framerate', str(self._fps), '-loglevel', 'error', '-i', input, '-vcodec', 'mpeg2video', '-pix_fmt', 'yuv420p', '-r', str(self._fps), '-y', '-b', bitrate,
|
||||
'-f', 'vob']
|
||||
|
||||
filters = []
|
||||
|
|
@ -335,8 +342,8 @@ class Timelapse(object):
|
|||
|
||||
|
||||
class ZTimelapse(Timelapse):
|
||||
def __init__(self, postRoll=0):
|
||||
Timelapse.__init__(self, postRoll=postRoll)
|
||||
def __init__(self, postRoll=0, fps=25):
|
||||
Timelapse.__init__(self, postRoll=postRoll, fps=fps)
|
||||
self._logger.debug("ZTimelapse initialized")
|
||||
|
||||
def eventSubscriptions(self):
|
||||
|
|
@ -370,8 +377,8 @@ class ZTimelapse(Timelapse):
|
|||
|
||||
|
||||
class TimedTimelapse(Timelapse):
|
||||
def __init__(self, postRoll=0, interval=1):
|
||||
Timelapse.__init__(self, postRoll=postRoll)
|
||||
def __init__(self, postRoll=0, interval=1, fps=25):
|
||||
Timelapse.__init__(self, postRoll=postRoll, fps=fps)
|
||||
self._interval = interval
|
||||
if self._interval < 1:
|
||||
self._interval = 1 # force minimum interval of 1s
|
||||
|
|
|
|||
Loading…
Reference in a new issue