ffmpeg - converting webm videos generated by Chrome is slow
Asked Answered
U

2

6

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!

Ube answered 28/6, 2018 at 10:49 Comment(0)
S
16

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
Sympathetic answered 28/6, 2018 at 11:11 Comment(2)
Changed the title so that your solution could be easier to spot by others.Ube
A note: Chrome's generated files do not set WebM's DefaultDuration (see the CL where it happened), and that probably causes the 1000fps misdetection.Bufflehead
T
0

I had the same slow-motion issue and garbled audio. Adding a "-r 30" fixed my issues as per Gyan's answer above.

Stream mapping:

Stream #0:0 -> #0:0 (vp9 (native) -> h264 (libx264))

Stream #0:1 -> #0:1 (opus (native) -> aac (native))

Teddman answered 2/6, 2024 at 9:6 Comment(2)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewMonostrophe
Take a look at streamlit discussion forum. Thats how forums should be.Teddman

© 2022 - 2025 — McMap. All rights reserved.