<-

ffmpeg cropper

Ever add a ffmpeg video that you wanted to crop?

But it’s a pain to do have the right crop filter 😟?

Introducing ffmpeg-cropper. Drag and drop your video and select the crop area. The tool will generate the ffmpeg filter for you (you can even play the video to check if the crop is correct).

Links:


Most important part of the code are

  • the drop zone

    <div
        ondrop="dropHandler(event);"
        ondragover="dragOverHandler(event, true);"
        ondragleave="dragOverHandler(event, false);"
    >

    The ondragover and ondragleave should call event.preventDefault(); to allow the drop

  • the (video) file to src conversion

    const fileURL = window.URL.createObjectURL(file);
    video = document.createElement("video");
    video.src = fileURL;

    Note that createObjectURL can use a lot of memory, so don’t forget to revoke the URL when you don’t need it anymore with window.URL.revokeObjectURL(fileURL);