Open viberfoner opened 1 year ago
Update: I edited the issue to include a repo for easier reproduction of the bug.
It appears the FFmpeg command you wrote is the culprit.
-t duration (input/output)
And your command was
-r 60 -pattern_type glob -i *.png -c:v libx264 -t 3 -pix_fmt yuv420p -vf scale=400:400 concat.mp4
where -t 3
was limiting the encoder to 3 seconds
removing this argument, I was able to get the full 300 frames to encode
Describe the bug I am creating a tool that captures frames from an HTML canvas and uses ffmpeg.wasm to make a video out of the frames. The way it works is it saves each frame as a PNG with
ffmpeg.FS()
, then uses a glob pattern inffmpeg.run()
to collect all of the frames and concatenate them into a video.The issue is that FFmpeg is exiting early (without error), causing the video to be cut short. It seems to always stop at 180 frames in both Firefox and Chrome. I have created a simpler version of the code that just uses one image for all of the frames (but still duplicates it multiple times in the FFmpeg FS) so that the code for capturing the canvas can be omitted.
To Reproduce
Clone the repo (https://github.com/viberfoner/ffmpeg-wasm-frame-limit-bug), install dependencies, and run the server locally.
Open http://localhost:8080 in your browser. Open dev tools and note that the frames stop encoding at 180, instead of finishing at 300.
Expected behavior FFmpeg should produce a 5 second long video with 300 frames. Instead, it stops at 180 frames.
Desktop:
Additional context This is my first time submitting an issue on GitHub, so please let me know if I can improve it!