Reputation: 557
Is it possible to use command like: ffmpeg -i video_1920.mp4 -vf scale=640:360 video_640.mp4 -hide_banner to reduce the resolution of a video in the pure JavaScript. For example I got a dropdown menu in which I have < a > tag, so I want to do a video quality selection by clicking on that menu hyperlink with JS. How to implement that properly, please help.
Upvotes: 9
Views: 27114
Reputation: 25481
If you want to do the work in the browser, i.e. on the users machine rather than your server, there are a number of projects which provide an ffmpeg wrapper in Javascript. This one is the most popular at the moment, I believe:
You would need to do some testing - video processing is very compute intensive and may not work well for you in the browser.
If you want to do it server side, in a Javascript based server like node for example, then again there are libraries available - e.g.:
Update 2022 - the following library is also worth looking at for browser side - I have used it and found it works well and the performance, leveraging web assembly language is noticeably better:
You do need to be aware of the need for SharedArrayBuffer support:
Only browsers with SharedArrayBuffer support can use ffmpeg.wasm, you can check HERE for the complete list.
The link referred to above is here: https://caniuse.com/sharedarraybuffer
Upvotes: 15