Skip to content

Open source CapCut alternative.

TypeScript
402 B
Raw Blame
/** Decode a base64 string to raw bytes. Shared by the media generators (image,
 * video, speech, music) that receive provider payloads inline as base64. */
export function bytesFromBase64(b64: string): Uint8Array<ArrayBuffer> {
  const bin = atob(b64);
  const bytes = new Uint8Array(new ArrayBuffer(bin.length));
  for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
  return bytes;
}