Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Mp3 to mp4 #165

Open
Hassnain243A opened this issue Sep 27, 2021 · 1 comment
Open

Merge Mp3 to mp4 #165

Hassnain243A opened this issue Sep 27, 2021 · 1 comment

Comments

@Hassnain243A
Copy link

I need to merge mp3 to mp4 in the browser with js. Is there any documentation here for that?

@ghost
Copy link

ghost commented Nov 6, 2021

var fs = require('fs')
var ffmpeg = require('ffmpeg.js/ffmpeg-mp4')

const audioPath = './res/433834921.mp3'`
const videoPath = './res/433834921.mp4'
const resultPath = './result/433834921.mp4'

const audioData = new Uint8Array(fs.readFileSync(audioPath))
const videoData = new Uint8Array(fs.readFileSync(videoPath))
// ffmpeg -i input.flv -i input.mp3 -c:v copy -c:a aac -strict experimental output.mp4
const result = ffmpeg({
    MEMFS: [{name: '433834921.mp3', data: audioData}, {name: '433834921.mp4', data: videoData}],
    arguments: ["-i", "433834921.mp3", "-i", "433834921.mp4", "-c:v", "copy", "-c:a", "aac", "-strict", "experimental", "out.mp4"],
})
const out = result.MEMFS[0];
fs.writeFileSync(resultPath, Buffer(out.data))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant