diff --git a/docs/api/settings.rst b/docs/api/settings.rst index c5947c4b5..466cb839a 100644 --- a/docs/api/settings.rst +++ b/docs/api/settings.rst @@ -254,6 +254,8 @@ mapped from the same fields in ``config.yaml`` unless otherwise noted: - * - ``webcam.ffmpegThreads`` - + * - ``webcam.ffmpegVideoCodec`` + - * - ``webcam.watermark`` - * - ``webcam.flipH`` diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index 79795f021..74fb7ed2d 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -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 diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index f5983769a..c064449a8 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -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"]) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 7e3575dd7..d97da7ac1 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -208,6 +208,7 @@ default_settings = { "snapshotSslValidation": True, "ffmpeg": None, "ffmpegThreads": 1, + "ffmpegVideoCodec": "mpeg2video", "bitrate": "5000k", "watermark": True, "flipH": False, diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index ee6c44ba1..40a96b2c9 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -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); diff --git a/src/octoprint/templates/dialogs/settings/webcam.jinja2 b/src/octoprint/templates/dialogs/settings/webcam.jinja2 index 7a1330edc..f9b72b069 100644 --- a/src/octoprint/templates/dialogs/settings/webcam.jinja2 +++ b/src/octoprint/templates/dialogs/settings/webcam.jinja2 @@ -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" %} diff --git a/src/octoprint/templates/snippets/settings/webcam/ffmpegVideoCodec.jinja2 b/src/octoprint/templates/snippets/settings/webcam/ffmpegVideoCodec.jinja2 new file mode 100644 index 000000000..920a534c6 --- /dev/null +++ b/src/octoprint/templates/snippets/settings/webcam/ffmpegVideoCodec.jinja2 @@ -0,0 +1,6 @@ +