DEV Community

loading...

How do you compress mp4 videos?

Khalyomede
Fullstack developer @ Carlili
・1 min read

Do you guys have a good online tool, command line tool or a Node.JS library to compress videos?

I would like to put a video I made today on a customer website, but I filmed it in 4k so for 15 sec. it weights 44MB 😂

The best tool that I am looking for would:

  • Trim useless bytes
  • Create variants by size (like 600x?, 980x?, 1200x?, 1920x?) with the ability to choose the sizes
  • Create a webm counterpart of the video (not necessary, but appreciated)

Anyone?

Discussion (6)

Collapse
iameugn profile image
imeugn

I will suggest ffmpeg as well. But there are some challenges, I think:

  1. It is slow. There is a bottleneck problem, which has not been quite resolved yet. Multithreading definitely helps though.
  2. Webm is not the best friend of ffmpeg. I had personally some problems with ffmpeg and webm. But for one video, it would suffice.
Collapse
khalyomede profile image
Khalyomede Author

I agree on both points, just ran ffmpeg to first resize my videos, it was quite slow, but I ask myself such a good tool might come with a cost.

Also, I struggled with the -crf ffmpeg option to make my webm version keep a good visual quality and reducing the weight (came up with a crf of 40 which divide the original video size by apoximatively 2, and a slight lesser quality but it is fine.

I really would have appreciated a Node.JS library for that 😁

Collapse
iameugn profile image
imeugn

I know, what you mean. But there some other approaches, I have seen, that might be getting better and better. Rust, Matlab, Scala etc.
If I am not mistaken, there is a half baked solution for Julia as well. I would still go for ffmpeg for the moment. It is the more complete solution, we have

Thread Thread
khalyomede profile image
Khalyomede Author

Good to know there is other languages on the way, thank you for your inputs!

Collapse
shindakun profile image
Steve Layton

ffmpeg is probably the best choice. You can even configure it to output multiple files, trac.ffmpeg.org/wiki/Creating%20mu....

Collapse
khalyomede profile image
Khalyomede Author

I guess it is the best way to achieve image resizing and converting to webm, thank you!

Forem Open with the Forem app