From 89e96b4de52656a557987c4a73f417406345842c Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Wed, 21 Feb 2024 17:14:01 -0300 Subject: [PATCH] video: Use unique identifier for video chunks identification --- src/stores/video.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/stores/video.ts b/src/stores/video.ts index 81a97b30e..99cc5c879 100644 --- a/src/stores/video.ts +++ b/src/stores/video.ts @@ -6,6 +6,7 @@ import fixWebmDuration from 'fix-webm-duration' import localforage from 'localforage' import { defineStore } from 'pinia' import Swal from 'sweetalert2' +import { v4 as uuid } from 'uuid' import { computed, ref, watch } from 'vue' import adapter from 'webrtc-adapter' @@ -157,10 +158,9 @@ export const useVideoStore = defineStore('video', () => { activeStreams.value[streamName]!.timeRecordingStart = new Date() const streamData = activeStreams.value[streamName] as StreamData - const fileName = `${missionStore.missionName || 'Cockpit'} (${format( - streamData.timeRecordingStart!, - 'LLL dd, yyyy - HH꞉mm꞉ss O' - )})` + const recordingHash = uuid().slice(0, 6) + const timeRecordingStartString = format(streamData.timeRecordingStart!, 'LLL dd, yyyy - HH꞉mm꞉ss O') + const fileName = `${missionStore.missionName || 'Cockpit'} (${timeRecordingStartString}) #${recordingHash}` activeStreams.value[streamName]!.mediaRecorder = new MediaRecorder(streamData.mediaStream!) if (!datalogger.logging()) { datalogger.startLogging() @@ -171,7 +171,7 @@ export const useVideoStore = defineStore('video', () => { activeStreams.value[streamName]!.mediaRecorder!.start(1000) let chunksCount = 0 activeStreams.value[streamName]!.mediaRecorder!.ondataavailable = async (e) => { - await tempVideoChunksDB.setItem(`${fileName}_${chunksCount}`, e.data) + await tempVideoChunksDB.setItem(`${recordingHash}_${chunksCount}`, e.data) chunksCount++ }