Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not try to process videos as soon as the recording stops #880

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/components/mini-widgets/MiniVideoRecorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div v-else>
<v-icon class="w-6 h-6 animate-spin" color="white">mdi-loading</v-icon>
</div>
<template v-if="!isRecording">
<template v-if="!isRecording && !isProcessingVideo">
<div
v-if="nameSelectedStream"
class="flex flex-col max-w-[50%] scroll-container transition-all border-blur cursor-pointer"
Expand All @@ -30,7 +30,7 @@
{{ timePassedString }}
</div>
<div v-else-if="isProcessingVideo" class="w-16 text-justify text-slate-100">
<div class="text-center text-xs text-white select-none flex-nowrap">Processing video...</div>
<div class="text-xs text-center text-white select-none flex-nowrap">Processing video...</div>
</div>
<div v-if="numberOfVideosOnDB > 0" class="flex justify-center w-8">
<v-divider vertical class="h-6" />
Expand All @@ -41,7 +41,7 @@
class="cursor-pointer"
@click="isVideoLibraryDialogOpen = true"
>
<v-icon class="w-6 h-6 text-slate-100 ml-3" @click="isVideoLibraryDialogOpen = true">
<v-icon class="w-6 h-6 ml-3 text-slate-100" @click="isVideoLibraryDialogOpen = true">
mdi-video-box
</v-icon></v-badge
>
Expand Down Expand Up @@ -151,6 +151,7 @@ const fetchNumebrOfTempVideos = async (): Promise<void> => {
await videoStore.videoStoringDB.iterate((value, key) => {
key.endsWith('.webm') && numberOfVideos++
})
Object.values(videoStore.keysFailedUnprocessedVideos).forEach(() => numberOfVideos++)
numberOfVideosOnDB.value = numberOfVideos
}

Expand All @@ -176,7 +177,6 @@ const toggleRecording = async (): Promise<void> => {
if (isRecording.value) {
if (nameSelectedStream.value !== undefined) {
videoStore.stopRecording(nameSelectedStream.value)
isProcessingVideo.value = true
}
return
}
Expand Down Expand Up @@ -273,6 +273,11 @@ watch(
}
)

watch(
() => videoStore.keysFailedUnprocessedVideos,
() => fetchNumebrOfTempVideos()
)

watch(
() => isVideoLibraryDialogOpen.value,
async (newValue) => {
Expand Down
23 changes: 3 additions & 20 deletions src/stores/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ export const useVideoStore = defineStore('video', () => {
info.dateFinish = new Date()
unprocessedVideos.value = { ...unprocessedVideos.value, ...{ [recordingHash]: info } }

await processVideoChunksAndTelemetry(recordingHash, info)

// Once the video is processed, we can delete it from the unprocessed videos list
delete unprocessedVideos.value[recordingHash]
activeStreams.value[streamName]!.mediaRecorder = undefined
}

Expand Down Expand Up @@ -408,16 +404,14 @@ export const useVideoStore = defineStore('video', () => {
const keysAllUnprocessedVideos = computed(() => Object.keys(unprocessedVideos.value))

const keysFailedUnprocessedVideos = computed(() => {
const dateNow = new Date(timeNow.value)

return keysAllUnprocessedVideos.value.filter((recordingHash) => {
const info = unprocessedVideos.value[recordingHash]

const secondsSinceLastRecordingUpdate = differenceInSeconds(dateNow, new Date(info.dateLastRecordingUpdate))
const secondsSinceLastRecordingUpdate = differenceInSeconds(timeNow.value, new Date(info.dateLastRecordingUpdate))
const recording = info.dateFinish === undefined && secondsSinceLastRecordingUpdate < 10

const dateLastProcessingUpdate = new Date(info.dateLastProcessignUpdate ?? 0)
const secondsSinceLastProcessingUpdate = differenceInSeconds(dateNow, dateLastProcessingUpdate)
const secondsSinceLastProcessingUpdate = differenceInSeconds(timeNow.value, dateLastProcessingUpdate)
const processing = info.dateFinish !== undefined && secondsSinceLastProcessingUpdate < 10

return !recording && !processing
Expand Down Expand Up @@ -478,18 +472,6 @@ export const useVideoStore = defineStore('video', () => {
}
}

// Warn user about videos that were not processed but are available to be processed
if (keysAllUnprocessedVideos.value.length > 0) {
const nUnprocVideos = keysAllUnprocessedVideos.value.length
Swal.fire({
title: 'Unprocessed videos detected',
text: `You have ${nUnprocVideos} ${nUnprocVideos === 1 ? 'video that was' : 'videos that were'} not processed.
This can happen if the app was closed while the video was being recorded, or if the app run out of memory
during the processing. Please go to the video page, in the configuration menu, to process or discard those.`,
icon: 'warning',
})
}

// Routine to make sure the user has chosen the allowed ICE candidate IPs, so the stream works as expected
let warningTimeout: NodeJS.Timeout | undefined = undefined
const iceIpCheckInterval = setInterval(async (): Promise<void> => {
Expand Down Expand Up @@ -603,6 +585,7 @@ export const useVideoStore = defineStore('video', () => {
downloadFilesFromVideoDB,
clearTemporaryVideoDB,
downloadTempVideoDB,
unprocessedVideos,
keysAllUnprocessedVideos,
keysFailedUnprocessedVideos,
areThereVideosProcessing,
Expand Down
Loading