diff --git a/server/src/OctoPrintConnection.ts b/server/src/OctoPrintConnection.ts index 38c7b08..06d5eb2 100644 --- a/server/src/OctoPrintConnection.ts +++ b/server/src/OctoPrintConnection.ts @@ -40,18 +40,13 @@ export default class OctoprintConnection { const webcamURL = new URL(settings.webcam.streamUrl, this.address); // TODO: handle recreating proxy on URL change if (this.webcamStream === undefined) { - this.webcamStream = make_mp4frag(this.slug, webcamURL); + this.webcamStream = make_mp4frag(this.slug, webcamURL, settings.webcam); } this.settingsMessage = { kind: "settings", printer: this.slug, name: settings.appearance.name, color: settings.appearance.color, - webcam: { - flipH: settings.webcam.flipH, - flipV: settings.webcam.flipV, - rotate90: settings.webcam.rotate90, - } } this.broadcast(this.settingsMessage); diff --git a/server/src/camera-stream.ts b/server/src/camera-stream.ts index ba7385b..2170d0d 100644 --- a/server/src/camera-stream.ts +++ b/server/src/camera-stream.ts @@ -1,7 +1,29 @@ import * as ffmpeg from 'fluent-ffmpeg'; import * as Mp4Frag from 'mp4frag'; -export function make_mp4frag(slug: string, url: URL | string): Mp4Frag { +interface WebcamSettings { + flipH: boolean; + flipV: boolean; + rotate90: boolean; +} + +export function make_mp4frag( + slug: string, + url: URL | string, + webcamSettings: WebcamSettings +): Mp4Frag { + let transforms = []; + if (webcamSettings.flipH) { + transforms.push('hflip'); + } + if (webcamSettings.flipV) { + transforms.push('vflip'); + } + if (webcamSettings.rotate90) { + transforms.push('transpose=2'); + } + console.log(transforms); + const command = ffmpeg(url.toString()) .nativeFramerate() .inputOptions([ @@ -12,7 +34,9 @@ export function make_mp4frag(slug: string, url: URL | string): Mp4Frag { .noAudio() .videoCodec('libx264') .size('640x480') + .autopad() .videoFilter('hqdn3d') + .videoFilters(transforms) .format('mp4') .outputOptions([ '-tune zerolatency', diff --git a/src/App.vue b/src/App.vue index 70af18b..907cf22 100644 --- a/src/App.vue +++ b/src/App.vue @@ -29,7 +29,7 @@