Skip to content

Commit

Permalink
Create overlay telemetry subtitle on video records
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Nov 23, 2023
1 parent d5142b0 commit 30bb006
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/mini-widgets/MiniVideoRecorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { computed, onBeforeMount, onBeforeUnmount, ref, toRefs, watch } from 'vu
import adapter from 'webrtc-adapter'
import { WebRTCManager } from '@/composables/webRTC'
import { assFromClog, datalogger } from '@/libs/logging'
import type { Stream } from '@/libs/webrtc/signalling_protocol'
import { useMainVehicleStore } from '@/stores/mainVehicle'
import { useMissionStore } from '@/stores/mission'
Expand Down Expand Up @@ -194,6 +195,14 @@ const startRecording = async (): Promise<SweetAlertResult | void> => {
timeRecordingStart.value = new Date()
const fileName = `${missionName || 'Cockpit'} (${format(timeRecordingStart.value, 'LLL dd, yyyy - HH꞉mm꞉ss O')})`
mediaRecorder.value = new MediaRecorder(mediaStream.value)
if (!datalogger.logging()) {
datalogger.startLogging()
}
const videoTrack = mediaStream.value.getVideoTracks()[0]
let videoDimensions = [1920, 1080]
if (videoTrack) {
videoDimensions = [videoTrack.getSettings().width || 1920, videoTrack.getSettings().width || 1080]
}
mediaRecorder.value.start(1000)
let chunks: Blob[] = []
mediaRecorder.value.ondataavailable = async (e) => {
Expand All @@ -203,8 +212,13 @@ const startRecording = async (): Promise<SweetAlertResult | void> => {
mediaRecorder.value.onstop = () => {
const blob = new Blob(chunks, { type: 'video/webm' })
const videoTelemetryLog = datalogger.getSlice(datalogger.currentCockpitLog, timeRecordingStart.value, new Date())
console.log(videoTelemetryLog)
const assLog = assFromClog(videoTelemetryLog, videoDimensions[0], videoDimensions[1])
var logBlob = new Blob([assLog], { type: 'text/plain' })
fixWebmDuration(blob, Date.now() - timeRecordingStart.value.getTime()).then((fixedBlob) => {
saveAs(fixedBlob, fileName)
saveAs(fixedBlob, `${fileName}.webm`)
saveAs(logBlob, `${fileName}.ass`)
cockpitVideoDB.removeItem(fileName)
})
chunks = []
Expand Down

0 comments on commit 30bb006

Please sign in to comment.