Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg - converting webm videos generated by Chrome is slow

Tags:

ffmpeg

webrtc

I generate webm files in two different ways. One using Chrome WebRTC MediaRecorder, the other one is using a js library which generates the webm video frame by frame (webm-writer-js). The file size of the videos generated is not that different, the fast one is 60% of the slow one but the difference in speed is 1000%

Using the basic ffmpeg syntax -i input.webm output.mp4 the files created with Chrome's media recorder take in fact almost 10x time to be converted. The conversion logs differ slightly but overall look very similar to my novice eyes. On the left the fast conversion and on the right the slow one.

enter image description here

The fast one throws a little error but the conversion seems successful. In the slow conversion you can see many frames processed, in the fast one as if there was only one (very fast). Using -preset veryfast cuts the speed time by half to both but the loss of quality is visible.

Any idea how I could speed up the conversion for the videos generated by Chrome without compromising much in quality? Thanks a lot!

like image 722
Nuthinking Avatar asked Dec 13 '22 15:12

Nuthinking


1 Answers

Chrome's files are detected as having a frame rate of 1000/s. It should be 30 fps.

Two workarounds - force video sync to variable frame rate

-i input.webm -vsync vfr output.mp4

or force an output rate

-i input.webm -r 30 output.mp4
like image 176
Gyan Avatar answered May 15 '23 00:05

Gyan