-
-
Notifications
You must be signed in to change notification settings - Fork 337
Description
I'm attempting to take a PNG or JPG and a WAV file and combine them into a simple video which just displays the static image and plays the audio.
This command works for ffmpeg in the command line and produces a 5 second video:
ffmpeg -loop 1 -y -i "BAT.PNG" -i "BAT.WAV" -c:v libx264 -c:a aac -b:a 48k -pix_fmt yuv420p -t 5000ms out.mp4
I'm trying to do this using ffmpeg.js now. Reading ancient issues on the tracker from 2016, the developer claimed that PNG decoding wasn't included in the module and I couldn't find evidence it had been added since. So I'm just trying with a JPG file and a WAV file now.
I've tried loading the two files in the two different ways listed in the README:
const ffmpeg = require("ffmpeg.js/ffmpeg-mp4.js");
const fs = require("fs");
const audioData = new Uint8Array(fs.readFileSync("BAT.WAV"));
const imageData = new Uint8Array(fs.readFileSync("BAT.JPG"));
const result = ffmpeg({
MEMFS: [{name: "BAT.JPG", data: imageData}, {name: "BAT.WAV", data: audioData}],
arguments: ["-loop", "1", "-i", "BAT.JPG", "-i", "BAT.WAV", "-c:v", "libx264", "-c:a", "aac", "-b:a", "48k", "-pix_fmt", "yuv420p", "-t", "7000ms", "soup.mp4"],
});
console.log(result);
and
const ffmpeg = require("ffmpeg.js/ffmpeg-mp4.js");
const result = ffmpeg({
mounts: [{type: "NODEFS", opts: {root: "."}, mountpoint: "/data"}],
arguments: ["-loop", "1", "-y", "-i", "/data/BAT.JPG", "-i", "/data/BAT.WAV", "-c:v", "libx264", "-c:a", "aac", "-b:a", "48k", "-pix_fmt", "yuv420p", "-t", "7000ms", "/data/out.mp4"],
});
console.log(result);
Both produce the same "Bad mount point" error:
var c=a.mountpoint;if(!c.match(/^\/[^\/]+$/)||"/."===c||"/.."===c||"/tmp"===c||"/home"===c||"/dev"===c||"/work"===c)throw Error("Bad mount point");
If I remove the image file and only attempt to load the audio, it successfully produces an MP4 file with no visual component. If I remove the WAV file and try to have a silent video with just the image, I get the error.
Any idea what I'm doing wrong with regard to loading in image files?