Real-time progress updates
FFmpeg emits progress events throughout the compression process, which the app uses to update the UI in real-time:renderer.js
The
progress object contains a percent property that indicates the current completion percentage of the compression operation.How it works
FFmpeg emits progress event
As FFmpeg processes the video, it periodically emits progress events with the current completion percentage.
Update progress bar
The progress bar’s width is dynamically adjusted to reflect the completion percentage:
renderer.js
Progress bar implementation
The progress bar is implemented using HTML and CSS, with JavaScript controlling its width:HTML structure
index.html
JavaScript integration
The progress bar element is referenced at the top of the renderer script:renderer.js
Dynamic width updates
During compression, the progress bar’s width is updated to match the completion percentage:renderer.js
- 0% complete
- 50% complete
- 100% complete
Progress events from FFmpeg
FFmpeg’s fluent API provides three key events for tracking compression status:progress event
progress event
Fired continuously during compression with percentage updates:This event allows you to provide real-time feedback to users about how long the compression will take.
renderer.js
end event
end event
Fired when compression completes successfully:When compression finishes, the progress bar is reset to 0% and a completion message is displayed.
renderer.js
error event
error event
Fired when compression fails:If an error occurs, the progress bar is reset and an error message is shown to the user.
renderer.js
Progress bar reset
The progress bar is automatically reset to 0% in two scenarios:-
Compression completes successfully
renderer.js
-
Compression fails with an error
renderer.js
Console logging
All progress updates are logged to the console for debugging and monitoring:renderer.js
The progress percentage is rounded to the nearest whole number before display, so you’ll see values like 0%, 1%, 2%, etc., rather than decimal percentages.