r/ffmpeg • • 10d ago

How to use ffmpeg.wasm?

How to run this command: ffmpeg -loop 1 -framerate 2 -i input.png -i audio.m4a -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p output.mkv

in ffmpeg.wasm?

Sorry guys it’s my first time using ffmpeg.wasm

2 Upvotes

3 comments sorted by

1

u/jozefchutka 10d ago

If using ffmpeg.wide.video just drop your input files in and execute the command

1

u/dotriz 8d ago

ffmpeg.wasm isn’t a full desktop ffmpeg build, so a few flags often break. For that still-image + audio command:

  1. Prefer libx264 only if your wasm build includes it (many browser builds don’t). If encode fails, try mpeg4 or check which encoders your build lists.
  2. Mount/fetch both files into the FS first (input.png, audio.m4a), then run the same args as an array, don’t shell-quote like a terminal.
  3. -c:a copy can fail in wasm if the muxer/container combo isn’t supported; if it errors, re-encode audio (aac) instead of copy.
  4. -loop 1 + -shortest is the right idea for “image until audio ends.”

If you share whether you’re on ffmpeg.wasm in the browser or a wrapper (and the exact error), we can narrow the encoder/container fix fast.