Skip to content

Commit

Permalink
feat: use h264
Browse files Browse the repository at this point in the history
  • Loading branch information
maltoze committed Aug 29, 2023
1 parent 6a9c55c commit 847df51
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/recording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let startTime: number
let media: MediaStream | undefined
let drawIntervalId: ReturnType<typeof setInterval>

const recorderMimeType = 'video/webm;codecs=h264'
const frameRate = 30
const bitRate = 8 * 1024 * 1024
const devicePixelRatio = window.devicePixelRatio || 1
Expand Down Expand Up @@ -116,14 +117,14 @@ export async function start(
}

recorder = new MediaRecorder(recorderMedia, {
mimeType: 'video/webm',
mimeType: recorderMimeType,
videoBitsPerSecond: bitRate,
})

recorder.ondataavailable = (event) => data.push(event.data)
recorder.onstop = async () => {
const duration = Date.now() - startTime
const blob = new Blob(data, { type: 'video/webm' })
const blob = new Blob(data, { type: recorderMimeType })
const fixedBlob = await fixWebmDuration(blob, duration, { logger: false })

callback?.()
Expand Down

0 comments on commit 847df51

Please sign in to comment.