Closed DeanVanGreunen closed 1 year ago
Please use time
instead as progress is highly experimental and lots of edge cases are not covered.
@jeromewu what does the time
value represent? time remaining, time passed, ???
@jeromewu how would I get the duration of the video? here is a snippet of my code
import { FFmpeg } from '@ffmpeg/ffmpeg';
import { fetchFile } from '@ffmpeg/util';
const baseURL = 'https://unpkg.com/@ffmpeg/core@0.12.2/dist/umd'
const ffmpeg = ffmpegRef.current;
ffmpeg.on("progress", ({ progress, time }) => {
console.log("PROGRESS DATA", progress, time);
// TODO: CALCULATE THE PERCENTAGE SOMEHOW
//setPercentage(Math.round(progress * 100));
});
ffmpeg.on("log", ({ message }) => {
console.log("LOG DATA", message);
});
await ffmpeg.load({
coreURL: await toBlobURL(
`${baseURL}/ffmpeg-core.js`,
"text/javascript",
),
wasmURL: await toBlobURL(
`${baseURL}/ffmpeg-core.wasm`,
"application/wasm",
),
});
let fileWritten = await ffmpeg.writeFile(
`${questionData.id}.webm`, await fetchFile(blob)
);
let converted = await ffmpeg.exec([
'-i', `${questionData.id}.webm`, // Input File
'-c:v', 'libx264',
'-preset', 'ultrafast',
'-vprofile', 'high',
'-pix_fmt', 'yuv420p',
'-r', '15', // Frame Rate
'-c:a', 'copy',
'-crf', '32',
'-vf', 'scale=320:-1', // Filter -> Scale image to 320px width, maintaining aspect ratio
`${questionData.id}-compressed.mp4` // Output File
]);
https://superuser.com/questions/650291/how-to-get-video-duration-in-seconds
You can get output using on('log', ...)
@DeanVanGreunen did you get this working?
@DeanVanGreunen did you get this working?
Sadly not, haven't tested the newer versions yet, so it might have been fixed, I suggest you pull/include the new version and give it a test
Describe the bug
progress
value from the ProgressEvent is a large negative number like -12202300 (for example)To Reproduce
Expected behavior
progress
value from the ProgressEvent is supposed to be in the range of 0 to 1 as a floating point number.Desktop (please complete the following information):