From 2dbbb0201debeaa6aa0c60c866345f0891d2d3da Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Thu, 23 Nov 2023 23:41:52 -0300 Subject: [PATCH] Create overlay telemetry subtitle on video records --- .../mini-widgets/MiniVideoRecorder.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/mini-widgets/MiniVideoRecorder.vue b/src/components/mini-widgets/MiniVideoRecorder.vue index 31330bbd9..84b090335 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 { 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,16 @@ 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 vWidth = 1920 + let vHeight = 1080 + if (videoTrack) { + vWidth = videoTrack.getSettings().width || vWidth + vHeight = videoTrack.getSettings().height || vHeight + } mediaRecorder.value.start(1000) let chunks: Blob[] = [] mediaRecorder.value.ondataavailable = async (e) => { @@ -203,8 +214,12 @@ 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()) + const assLog = datalogger.toAssOverlay(videoTelemetryLog, vWidth, vHeight, timeRecordingStart.value.getTime()) + 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 = []