Update examples
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
const fs = require('fs');
|
||||
const { createFFmpeg } = require('../../src');
|
||||
const { createFFmpeg, fetchFile } = require('../../src');
|
||||
|
||||
const ffmpeg = createFFmpeg({ log: true });
|
||||
|
||||
(async () => {
|
||||
await ffmpeg.load();
|
||||
await ffmpeg.write('audio.ogg', '../../tests/assets/triangle/audio.ogg');
|
||||
ffmpeg.FS('writeFile', 'audio.ogg', await fetchFile('../assets/triangle/audio.ogg'));
|
||||
for (let i = 0; i < 60; i += 1) {
|
||||
const num = `00${i}`.slice(-3);
|
||||
await ffmpeg.write(`tmp.${num}.png`, `../../tests/assets/triangle/tmp.${num}.png`);
|
||||
ffmpeg.FS('writeFile', `tmp.${num}.png`, await fetchFile(`../assets/triangle/tmp.${num}.png`));
|
||||
}
|
||||
await ffmpeg.run('-framerate 30 -pattern_type glob -i *.png -i audio.ogg -c:a copy -shortest -c:v libx264 -pix_fmt yuv420p out.mp4');
|
||||
await ffmpeg.remove('audio.ogg');
|
||||
console.log(ffmpeg.FS('readdir', '/'));
|
||||
await ffmpeg.run('-framerate', '30', '-pattern_type', 'glob', '-i', '*.png', '-i', 'audio.ogg', '-c:a', 'copy', '-shortest', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', 'out.mp4');
|
||||
await ffmpeg.FS('unlink', 'audio.ogg');
|
||||
for (let i = 0; i < 60; i += 1) {
|
||||
const num = `00${i}`.slice(-3);
|
||||
await ffmpeg.remove(`tmp.${num}.png`);
|
||||
await ffmpeg.FS('unlink', `tmp.${num}.png`);
|
||||
}
|
||||
fs.writeFileSync('out.mp4', ffmpeg.read('out.mp4'));
|
||||
fs.writeFileSync('out.mp4', ffmpeg.FS('readFile', 'out.mp4'));
|
||||
process.exit(0);
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user