Philip
Philip

Reputation: 241

Crop resolution and trim video length in JS client side before uploading?

I wanna enable users of my web app to upload videos with a maximum lenght of 10s and cropped/scaled to a certain resolution. There for users should be able to trim there selected video to 10s before uploading it with a simple editor.

Is there any library or examples enabling client side video editting to cut video length as well as croping before uploading it to a server? I found some canvas approaches for filters, single video frames and export to webM videos but nothing bringing it all together. So anyone done that before?

Apreciate any ideas :)

Upvotes: 1

Views: 2829

Answers (1)

Konrad Przydział
Konrad Przydział

Reputation: 296

Tipicaly video processing is a server thing because it's easier to find and run complex (often compiled) libraries (like ffmpeg) there than in browser and it may cause less performance problems for end user. Anyway I think there are two options:

1. Process video on server - send file and configuration

The first approach assume that you prepare client side "editor" based on canvas which simulate video editing. After setup of all filters, crops etc. the client might send original video file and video processing configuration which would be used on a server to do the same thing

Depends on which language you prefer on backend side implementation might be different so I don't give you ready snippet of code.

Of course you can switch order of tasks and upload original file at first place then smiulate video processing on client side and after all send mentioned configuration to backend and process video.

2. Process video within WebAssembly

If you really need to keep everything on client side you can try with WebAssembly ports of libraries like https://github.com/ffmpegwasm/ffmpeg.wasm and send already processed video file to server.

Upvotes: 3

Related Questions