timelapse: add setting for videocodec
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
1 parent
bd7a28af5b
commit
f577d6b45d
8 files changed
+27
-5
No files matched your search
@@ -254,6 +254,8 @@ mapped from the same fields in ``config.yaml`` unless otherwise noted:
|
||||
-
|
||||
* - ``webcam.ffmpegThreads``
|
||||
-
|
||||
* - ``webcam.ffmpegVideoCodec``
|
||||
-
|
||||
* - ``webcam.watermark``
|
||||
-
|
||||
* - ``webcam.flipH``
|
||||
|
||||
@@ -1194,6 +1194,9 @@ Use the following settings to configure webcam support:
|
||||
# Should be left at 1 for RPi1.
|
||||
ffmpegThreads: 1
|
||||
|
||||
# Videocodec to be used for encoding. Defaults to mpeg2video.
|
||||
ffmpegVideoCodec: mpeg2video
|
||||
|
||||
# The bitrate to use for rendering the timelapse video. This gets directly passed to ffmpeg.
|
||||
bitrate: 5000k
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ def getSettings():
|
||||
"ffmpegPath": s.get(["webcam", "ffmpeg"]),
|
||||
"bitrate": s.get(["webcam", "bitrate"]),
|
||||
"ffmpegThreads": s.get(["webcam", "ffmpegThreads"]),
|
||||
"ffmpegVideoCodec": s.get(["webcam", "ffmpegVideoCodec"]),
|
||||
"watermark": s.getBoolean(["webcam", "watermark"]),
|
||||
"flipH": s.getBoolean(["webcam", "flipH"]),
|
||||
"flipV": s.getBoolean(["webcam", "flipV"]),
|
||||
@@ -348,6 +349,8 @@ def _saveSettings(data):
|
||||
if "ffmpegPath" in data["webcam"]: s.set(["webcam", "ffmpeg"], data["webcam"]["ffmpegPath"])
|
||||
if "bitrate" in data["webcam"]: s.set(["webcam", "bitrate"], data["webcam"]["bitrate"])
|
||||
if "ffmpegThreads" in data["webcam"]: s.setInt(["webcam", "ffmpegThreads"], data["webcam"]["ffmpegThreads"])
|
||||
# Add a whitelist for vcodecs like aspect ration has?
|
||||
if "ffmpegVideoCodec" in data["webcam"]: s.set(["webcam", "ffmpegVideoCodec"], data["webcam"]["ffmpegVideoCodec"])
|
||||
if "watermark" in data["webcam"]: s.setBoolean(["webcam", "watermark"], data["webcam"]["watermark"])
|
||||
if "flipH" in data["webcam"]: s.setBoolean(["webcam", "flipH"], data["webcam"]["flipH"])
|
||||
if "flipV" in data["webcam"]: s.setBoolean(["webcam", "flipV"], data["webcam"]["flipV"])
|
||||
|
||||
@@ -208,6 +208,7 @@ default_settings = {
|
||||
"snapshotSslValidation": True,
|
||||
"ffmpeg": None,
|
||||
"ffmpegThreads": 1,
|
||||
"ffmpegVideoCodec": "mpeg2video",
|
||||
"bitrate": "5000k",
|
||||
"watermark": True,
|
||||
"flipH": False,
|
||||
|
||||
@@ -129,6 +129,7 @@ $(function() {
|
||||
self.webcam_ffmpegPath = ko.observable(undefined);
|
||||
self.webcam_bitrate = ko.observable(undefined);
|
||||
self.webcam_ffmpegThreads = ko.observable(undefined);
|
||||
self.webcam_ffmpegVideoCodec = ko.observable(undefined);
|
||||
self.webcam_watermark = ko.observable(undefined);
|
||||
self.webcam_flipH = ko.observable(undefined);
|
||||
self.webcam_flipV = ko.observable(undefined);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
{% include "snippets/settings/webcam/ffmpegThreads.jinja2" %}
|
||||
{% include "snippets/settings/webcam/webcamSnapshotTimeout.jinja2" %}
|
||||
{% include "snippets/settings/webcam/webcamSnapshotSslValidation.jinja2" %}
|
||||
{% include "snippets/settings/webcam/ffmpegVideoCodec.jinja2" %}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,6 @@
|
||||
<div class="control-group" title="{{ _('Videocodec uses for encoding') }}">
|
||||
<label class="control-label" for="settings-webcam_ffmpegVideoCodec">{{ _('Videocodec') }}</label>
|
||||
<div class="controls">
|
||||
<input class="input-mini" data-bind="value: webcam_ffmpegVIdeoCodec" id="settings-webcamFfmpegVideoCodec" type="text">
|
||||
</div>
|
||||
</div>
|
||||
@@ -165,6 +165,7 @@ def render_unrendered_timelapse(name, gcode=None, postfix=None, fps=25):
|
||||
capture_dir = settings().getBaseFolder("timelapse_tmp")
|
||||
output_dir = settings().getBaseFolder("timelapse")
|
||||
threads = settings().get(["webcam", "ffmpegThreads"])
|
||||
videocodec = settings().get(["webcam", "ffmpegVideoCodec"])
|
||||
|
||||
job = TimelapseRenderJob(capture_dir, output_dir, name,
|
||||
postfix=postfix,
|
||||
@@ -172,6 +173,7 @@ def render_unrendered_timelapse(name, gcode=None, postfix=None, fps=25):
|
||||
output_format=_output_format,
|
||||
fps=fps,
|
||||
threads=threads,
|
||||
videocodec=videocodec,
|
||||
on_start=_create_render_start_handler(name, gcode=gcode),
|
||||
on_success=_create_render_success_handler(name, gcode=gcode),
|
||||
on_fail=_create_render_fail_handler(name, gcode=gcode),
|
||||
@@ -786,7 +788,7 @@ class TimelapseRenderJob(object):
|
||||
|
||||
def __init__(self, capture_dir, output_dir, prefix, postfix=None, capture_glob="{prefix}-*.jpg",
|
||||
capture_format="{prefix}-%d.jpg", output_format="{prefix}{postfix}.mpg", fps=25, threads=1,
|
||||
on_start=None, on_success=None, on_fail=None, on_always=None):
|
||||
videocodec="mpeg2video", on_start=None, on_success=None, on_fail=None, on_always=None):
|
||||
self._capture_dir = capture_dir
|
||||
self._output_dir = output_dir
|
||||
self._prefix = prefix
|
||||
@@ -796,6 +798,7 @@ class TimelapseRenderJob(object):
|
||||
self._output_format = output_format
|
||||
self._fps = fps
|
||||
self._threads = threads
|
||||
self._videocodec = videocodec
|
||||
self._on_start = on_start
|
||||
self._on_success = on_success
|
||||
self._on_fail = on_fail
|
||||
@@ -853,7 +856,8 @@ class TimelapseRenderJob(object):
|
||||
|
||||
# prepare ffmpeg command
|
||||
command_str = self._create_ffmpeg_command_string(ffmpeg, self._fps, bitrate, self._threads, input, output,
|
||||
hflip=hflip, vflip=vflip, rotate=rotate, watermark=watermark)
|
||||
self._videocodec, hflip=hflip, vflip=vflip, rotate=rotate,
|
||||
watermark=watermark)
|
||||
self._logger.debug("Executing command: {}".format(command_str))
|
||||
|
||||
with self.render_job_lock:
|
||||
@@ -904,7 +908,7 @@ class TimelapseRenderJob(object):
|
||||
return (int(hours) * 60 + int(minutes)) * 60 + int(seconds)
|
||||
|
||||
@classmethod
|
||||
def _create_ffmpeg_command_string(cls, ffmpeg, fps, bitrate, threads, input, output, hflip=False, vflip=False,
|
||||
def _create_ffmpeg_command_string(cls, ffmpeg, fps, bitrate, threads, input, output, videocodec, hflip=False, vflip=False,
|
||||
rotate=False, watermark=None, pixfmt="yuv420p"):
|
||||
"""
|
||||
Create ffmpeg command string based on input parameters.
|
||||
@@ -914,7 +918,8 @@ class TimelapseRenderJob(object):
|
||||
fps (int): Frames per second for output
|
||||
bitrate (str): Bitrate of output
|
||||
threads (int): Number of threads to use for rendering
|
||||
input (str): Absolute path to input files including file mask
|
||||
videocodec (str): Videocodec to be used for encoding
|
||||
input (str): Absolute path to input files including file mask
|
||||
output (str): Absolute path to output file
|
||||
hflip (bool): Perform horizontal flip on input material.
|
||||
vflip (bool): Perform vertical flip on input material.
|
||||
@@ -931,7 +936,7 @@ class TimelapseRenderJob(object):
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
command = [
|
||||
ffmpeg, '-framerate', str(fps), '-i', '"{}"'.format(input), '-vcodec', 'mpeg2video',
|
||||
ffmpeg, '-framerate', str(fps), '-i', '"{}"'.format(input), '-vcodec', videocodec,
|
||||
'-threads', str(threads), '-r', "25", '-y', '-b', str(bitrate),
|
||||
'-f', 'vob']
|
||||
|
||||
|
||||
Reference in new issue
Block a user