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 24, 2023
1 parent 199d150 commit 2dbbb02
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 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 { 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,16 @@ 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 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) => {
Expand All @@ -203,8 +214,12 @@ 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())
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 = []
Expand Down

0 comments on commit 2dbbb02

Please sign in to comment.