mx / src /video /XDebug.tsx
Ethscriptions's picture
Step 6-7: 播放器 + MP4 导出 + 文案 + 封面
d61897b verified
Raw History Blame Contribute Delete
632 Bytes
import { useEffect } from 'react'
import { exportMp4 } from './exporter'
export default function XDebug() {
useEffect(() => {
const w = window as unknown as { __done: boolean; __mp4: string }
exportMp4(24, () => {}, new AbortController().signal, 3).then(async b => {
const u8 = new Uint8Array(await b.arrayBuffer()); let bin = ''
for (let i = 0; i < u8.length; i += 0x8000) bin += String.fromCharCode(...u8.subarray(i, i + 0x8000))
w.__mp4 = btoa(bin); console.log('INFO mp4 bytes ' + b.size)
}).catch(e => console.log('INFO ERROR ' + e)).finally(() => { w.__done = true })
}, [])
return null
}