Skip to content

Commit

Permalink
video: Use unique identifier for video chunks identification
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Feb 21, 2024
1 parent 9bd9246 commit 89e96b4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/stores/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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()
Expand All @@ -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++
}

Expand Down

0 comments on commit 89e96b4

Please sign in to comment.