How to trim a video/audio recorded html media api in javascript

After recording a video or audio, I want users to be able to cut and save the only part of the video they want. I want this done in javascript frontend without sending it to the backend first.

I’ll appreciate any help from anyone.

Thanks.

I have checked online but haven’t been lucky to see a working solution. I hope I will be able to get some help here.