clapper / src /services /io /fileDataToBase64.ts
jbilcke-hf's picture
jbilcke-hf HF staff
first version of the video analyzer
5bd8810
raw
history blame
No virus
392 Bytes
import { FileData } from '@ffmpeg/ffmpeg/dist/esm/types'
export function fileDataToBase64(fileData: FileData): string {
// Convert Uint8Array to Base64 string without using btoa
let binary = ''
const bytes = new Uint8Array(fileData as any)
const len = bytes.byteLength
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i])
}
return window.btoa(binary)
}