Skip to content

Commit

Permalink
feat: add option to hide FPS counter in webcams (#1488)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Aug 9, 2023
1 parent e9c22d3 commit 69eaeb6
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 3 deletions.
30 changes: 30 additions & 0 deletions src/components/settings/Webcams/WebcamForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@
:label="$t('Settings.WebcamsTab.Rotate')" />
</v-col>
</v-row>
<v-row v-if="hasFpsCounter">
<v-col class="pt-1 pb-3">
<v-checkbox
v-model="hideFps"
class="mt-1"
hide-details
:label="$t('Settings.WebcamsTab.HideFps')" />
</v-col>
</v-row>
<v-row>
<v-col class="pt-1 pb-3">
<div class="v-label v-label--active theme--dark text-subtitle-1">
Expand Down Expand Up @@ -250,6 +259,27 @@ export default class WebcamForm extends Mixins(BaseMixin, WebcamMixin) {
return classes
}
get hasFpsCounter() {
return ['mjpegstreamer', 'mjpegstreamer-adaptive'].includes(this.webcam.service)
}
get hideFps() {
return this.webcam.extra_data?.hideFps ?? false
}
set hideFps(newVal) {
if (!('extra_data' in this.webcam)) {
this.webcam.extra_data = {
hideFps: newVal,
}
return
}
// @ts-ignore
this.webcam.extra_data.hideFps = newVal
}
mounted() {
this.oldWebcamName = this.webcam.name
}
Expand Down
8 changes: 7 additions & 1 deletion src/components/webcams/Mjpegstreamer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class="webcamImage"
:style="webcamStyle"
@load="onload" />
<span v-if="showFps" class="webcamFpsOutput">{{ $t('Panels.WebcamPanel.FPS') }}: {{ fpsOutput }}</span>
<span v-if="showFpsCounter" class="webcamFpsOutput">{{ $t('Panels.WebcamPanel.FPS') }}: {{ fpsOutput }}</span>
</div>
</template>

Expand Down Expand Up @@ -72,6 +72,12 @@ export default class Mjpegstreamer extends Mixins(BaseMixin, WebcamMixin) {
return this.currentFPS < 10 ? '0' + this.currentFPS.toString() : this.currentFPS
}
get showFpsCounter() {
if (!this.showFps) return false
return !(this.camSettings.extra_data?.hideFps ?? false)
}
startStream() {
if (this.streamState) return
this.streamState = true
Expand Down
8 changes: 7 additions & 1 deletion src/components/webcams/MjpegstreamerAdaptive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
height="400"
:style="webcamStyle"
:class="'webcamImage ' + (isLoaded ? '' : 'hiddenWebcam')"></canvas>
<span v-if="isLoaded && showFps" class="webcamFpsOutput">
<span v-if="isLoaded && showFpsCounter" class="webcamFpsOutput">
{{ $t('Panels.WebcamPanel.FPS') }}: {{ fpsOutput }}
</span>
</div>
Expand Down Expand Up @@ -74,6 +74,12 @@ export default class MjpegstreamerAdaptive extends Mixins(BaseMixin, WebcamMixin
return this.currentFPS < 10 ? '0' + this.currentFPS.toString() : this.currentFPS
}
get showFpsCounter() {
if (!this.showFps) return false
return !(this.camSettings.extra_data?.hideFps ?? false)
}
get rotate() {
return [90, 270].includes(this.camSettings.rotation ?? 0)
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@
"EditWebcam": "Webcam bearbeiten",
"FlipWebcam": "Webcam-Bild spiegeln:",
"Hlsstream": "HLS-Stream",
"HideFps": "FPS-Anzeige verstecken",
"Horizontally": "horizontal",
"IconBed": "Bett",
"IconCam": "Kamera",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@
"EditCrowsnestConf": "Edit crowsnest.conf",
"EditWebcam": "Edit Webcam",
"FlipWebcam": "Flip webcam image:",
"HideFps": "Hide FPS counter",
"Horizontally": "horizontally",
"IconBed": "Bed",
"IconCam": "Cam",
Expand Down
4 changes: 3 additions & 1 deletion src/store/gui/webcams/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export interface GuiWebcamStateWebcam {
flip_vertical: boolean
rotation: number
aspect_ratio?: string
extra_data?: {}
extra_data?: {
hideFps?: boolean
}
source?: 'config' | 'database'
}

0 comments on commit 69eaeb6

Please sign in to comment.