Code Monkey home page Code Monkey logo

video-encoding-service's Introduction

Video transcoding server

A NodeJS Express service to transcode video files

Features

  • Accepts any video input with auto specs detection (file type, content-type, codecs, containers, size, compressor, colors, dimensions - only works with no protected/encrypted files)
  • Creates a high compatibility .mp4 file output with good/balanced video and audio quality, dimension and file size
  • Queue/stack sequential background jobs based in Bull + Redis
  • Internal super simple sqlite database to keep the conversions status and history
  • Uses very useful libs (Babel, Nodemon, CORS, fluent-ffmpeg, Multer, Dotenv, Sequelize)
  • Based on widely used FFmpeg media encoder lib (using fluent-ffmpeg as a NodeJS wrapper)
  • Promise based callbacks to ensure reliability

Prerequisites

  • Docker server
  • Node & npm
  • Some free disk space

Running

  • Clone repo
  • cd video-service + npm i
  • docker-compose up --build
  • Default port is 8899

API

  • GET localhost:8899/conversions/ - Returns all conversions saved in DB (JSON)
{
    "id": <Int>,
    "filePath": "files/1574097740389_file_example_MOV_1280_1_4MB.mov",
    "convertedFilePath": "1574097740389_file_example_MOV_1280_1_4MB_1574100138423.mp4",
    "outputFormat": "mp4",
    "status": "pending",
    "createdAt": "2019-11-18T17:22:20.477Z",
    "updatedAt": "2019-11-18T18:02:31.874Z"
}

  • POST localhost:8899/conversions/ - Send the video file to the server and creates a new job
POST /conversions/ HTTP/1.1
Host: localhost:8899
Content-Type: multipart/form-data;
Accept: */*
Cache-Control: no-cache
Content-Disposition: form-data; name="video"; filename="<FILE_TO_UPLOAD_PATH>"
Content-Disposition: form-data; name="outputFormat"; VALUE="<OUTPUT_FORMAT>" // Default .mp4

  • GET localhost:8899/conversions/start/:id - Start the job/video encoding of given id (Returns a processing status object with a HTTP 200 if queue and video encoding process were created successfully)
{
    "id": <given_id>,
    "filePath": "files/1574097740389_file_example_MOV_1280_1_4MB.mov",
    "convertedFilePath": "1574097740389_file_example_MOV_1280_1_4MB_1574100138423.mp4",
    "outputFormat": "mp4",
    "status": "processing",
    "createdAt": "2019-11-18T17:22:20.477Z",
    "updatedAt": "2019-11-18T18:02:31.874Z"
}

  • DELETE localhost:8899/conversions/:id - Deletes the job with the given ID along with the original and converted file of the job

  • PUT localhost:8899/conversions/cancel/:id - Sets job status to cancelled (keeps the original file)

TODO

  • [service] Change the upload behavior to a URL source reading (from S3)
  • [service] Integrate the service with AWS S3 to read the video attachment and replace it with the converted media (lowest service and user impact)
  • [mobile] Handle media incompatible callback from video player to show "Video is processing" message to user

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.