Frontend2025년 11월 15일1분 읽기

FFmpeg WASM — 브라우저에서 동영상 편집하기

YS
YoungSam
조회 330

FFmpeg.wasm 설치

import { FFmpeg } from "@ffmpeg/ffmpeg";
import { fetchFile } from "@ffmpeg/util";

const ffmpeg = new FFmpeg();
await ffmpeg.load();

동영상 변환

// MP4 → GIF 변환
await ffmpeg.writeFile("input.mp4", await fetchFile(videoFile));
await ffmpeg.exec([
  "-i", "input.mp4",
  "-vf", "fps=10,scale=320:-1",
  "-t", "5",
  "output.gif"
]);
const data = await ffmpeg.readFile("output.gif");
const url = URL.createObjectURL(new Blob([data]));

활용

  • 썸네일 추출
  • 포맷 변환
  • 트리밍/자르기
FFmpegWASMVideo

댓글 0

아직 댓글이 없습니다.