GithubHelp home page GithubHelp logo

shotstack / mp4-to-webm-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 134 KB

A demo project showing how to convert an MP4 video to WEBM format using the Shotstack Ingest API.

Home Page: https://shotstack.io/demo/mp4-to-webm/

License: MIT License

JavaScript 61.77% HTML 33.84% CSS 4.39%
mp4-converter transcoding video video-convertor video-processing video-transcoding webm

mp4-to-webm-demo's Introduction

Shotstack MP4 to WEBM Demo

This sample application shows how you can use the Shotstack Ingest API to convert MP4 videos to WEBM format. The Ingest API is a video transformation API that lets you upload, store, and convert videos and images into different formats, sizes, frame rates, speeds, and more.

Using an HTML web form, users can upload a video or put in a URL of an MP4 video online. After submitting the form, the video is converted from MP4 to WEBM. Users can play the new WEBM file in their browsers or download it.

View the live demo at: https://shotstack.io/demo/mp4-to-webm/

The demo is made with Node.js and works with the Express Framework or as a serverless project using AWS Lambda and API Gateway.

Requirements

Project Structure

The project is divided into two components:

Backend API

The backend API has an endpoint that receives the video file URL. The parameters are prepared in the JSON format the Ingest API expects and sent to the API. A status endpoint is called to check the progress of the transformation. When the WEBM file is ready, the status is updated and the file URL of the WEBM file is returned.

The backend API source code is in the api directory.

Frontend Web Form & Player

The frontend uses Bootstrap and basic HTML to set up a form that allows the user to upload a video file or enter a file URL. We use jQuery for the interactive components of the application, to submit the data to the backend API and poll the status. There is also a video player that plays the final WEBM video file when it's ready.

The source code for the frontend is in the web directory.

Installation

Install node module dependencies:

cd api
npm install

Configuration

Copy the .env.dist file and rename it .env:

cp .env.dist .env

Replace the environment variables below with your Shotstack API key (stage key) and a writable S3 bucket name:

SHOTSTACK_API_KEY=replace_with_your_shotstack_key
SHOTSTACK_HOST=https://api.shotstack.io/ingest/stage/
AWS_S3_UPLOADS_BUCKET=replace_with_an_s3_bucket_name

Run Locally

To start the API and serve the frontend form (from the api directory):

Navigate to the api directory. And run the command below to start the API and serve the frontend form.

npm run start

Then visit http://localhost:3000.

Deploy Serverless Application (optional)

The project has been built as a serverless application using the Serverless Framework and AWS Lambda. To understand more about the Serverless Framework and how to set everything up consult the documentation: https://serverless.com/framework/docs/providers/aws/

To deploy to AWS Lambda (from the api directory):

npm run deploy

Once the API is deployed set the var apiEndpoint variable in web/app.js to the returned API Gateway URL.

Run the web/index.html file locally or use AWS S3 static hosting to serve the web page.

mp4-to-webm-demo's People

Contributors

benjaminsemah 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.