Skip to content

Commit

Permalink
Use fix-webm-duration lib to fix video blob duration
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Sep 15, 2023
1 parent 6637ad1 commit 658cd78
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/mini-widgets/MiniVideoRecorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import { useMouseInElement, useTimestamp } from '@vueuse/core'
import { format, intervalToDuration } from 'date-fns'
import { saveAs } from 'file-saver'
import fixWebmDuration from 'fix-webm-duration'
import Swal, { type SweetAlertResult } from 'sweetalert2'
import { computed, onBeforeMount, onBeforeUnmount, ref, toRefs, watch } from 'vue'
import adapter from 'webrtc-adapter'
Expand Down Expand Up @@ -184,8 +185,10 @@ const startRecording = async (): Promise<SweetAlertResult | void> => {
mediaRecorder.value.onstop = () => {
const blob = new Blob(chunks, { type: 'video/webm' })
fixWebmDuration(blob, Date.now() - timeRecordingStart.value.getTime()).then((fixedBlob) => {
saveAs(fixedBlob, `${missionName} (${format(timeRecordingStart.value, 'LLL dd, yyyy - HH꞉mm꞉ss O')})`)
})
chunks = []
saveAs(blob, `${missionName} (${format(timeRecordingStart.value, 'LLL dd, yyyy - HH꞉mm꞉ss O')})`)
mediaRecorder.value = undefined
if (selectedStream.value?.id === 'screenStream' && mediaStream.value !== undefined) {
// If recording the screen stream, stop the tracks also, so the browser removes the recording warning.
Expand Down

0 comments on commit 658cd78

Please sign in to comment.