Kagami / ffmpeg.js

Port of FFmpeg with Emscripten
Other
3.29k stars 335 forks source link

Converting WebM to Mp4? #124

Closed Richienb closed 4 years ago

Richienb commented 4 years ago

As far as I can tell, to convert a buffer of webm data to mp4, I should do this:

const ffmpeg = require("ffmpeg.js")

module.exports = webmData => ffmpeg({
    MEMFS: [{ name: "video.webm", data: Uint8Array.from(webmData) }],
    arguments: ["-i", "video.webm", "-codec", "copy", "output.mp4"],
}).MEMFS[0].data

However, in order for this code to work, I need to have imported the webm code and the mp4 code simultaneously. How do I fix this?

// @Kagami

Richienb commented 4 years ago

Discovered a solution:

const ffmpeg = require("ffmpeg.js/ffmpeg-mp4")

module.exports = webmData => ffmpeg({
    MEMFS: [{ name: "video.webm", data: Uint8Array.from(webmData) }],
    arguments: ["-i", "video.webm", "-codec", "copy", "-strict", "-2", "output.mp4"]
}).MEMFS[0].data