From 30bb00669dae1b61fc90c16431beb5dcede13a8b Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Wed, 22 Nov 2023 22:18:58 -0300 Subject: [PATCH] Create overlay telemetry subtitle on video records --- .../mini-widgets/MiniVideoRecorder.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/mini-widgets/MiniVideoRecorder.vue b/src/components/mini-widgets/MiniVideoRecorder.vue index 31330bbd9..620389c17 100644 --- a/src/components/mini-widgets/MiniVideoRecorder.vue +++ b/src/components/mini-widgets/MiniVideoRecorder.vue @@ -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' @@ -194,6 +195,14 @@ const startRecording = async (): Promise => { 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) => { @@ -203,8 +212,13 @@ const startRecording = async (): Promise => { 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 = []