Giter Site home page Giter Site logo

video-cropper's Introduction

video-cropper

Cropps your video. Eventually.

How to get the things up?

For convenience purposes, the application was dokerized along with the required version of ffmpeg.

So, starting the application is as easy as

docker build -t video-cropper .
docker run -p 8080:8080 --name video-cropper-test video-cropper

To crop the video, you need to make a POST request to the /video endpoint with the video file in body and appropriate Content-Type header value. The mp4 and avi video formats are supported.

High-level algorithm description

  1. Accept the request;
  2. Validate the file format;
  3. Generate UUID that will be used as the result file name;
  4. Return the response with a link to the file that will be eventually generated;
  5. Generate the result file:
    1. Pipe the request stream to a temp file with name, same as the future result file name;
    2. As soon as input is saved to the file, spawn ffmpeg process that will produce the result file;
    3. As soon as the ffmpeg process finishes - delete the temp file.

The response is being sent instantly because the processing can take a while. A while means up to infinity. Not all the clients can wait for an infinity, so it was decided that to return the response before we can make sure that the video is processable is still better than don't return the response at all.

Development log

From the very beginning the plan was to handle mp4 and avi differently.

In most of the cases, mp4 contains it's metadata at the end of the file. So it isn't always suitable for streaming. On the other hand, avi suits for streaming well. We could have benefit from that by skipping the buffering for avi and pass the request data stream directly to the ffmpeg process.

So, why do we use buffering for avi?

The problem is that controlling the ffmpeg process concurrency level is vital for application stability. That means that requests should be queued somehow. Obviously, we can't postpone the client data upload to the moment the turn comes. So, it was decided to apply buffering for all video formats.

One thing has left from the time the idea of the optimization was looking valid.

๐Ÿฅ

... An over engineered Croppers class structure.

video-cropper's People

Contributors

bohdanpetryshyn avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.