Skip to content

mahyarkarimi/ffmpeg-ms

Repository files navigation

FFMPEG microservice developed in python fastapi


A microservice for conversion of any sort of media using FFMPEG.

Quick start

Deploy using docker


Dockerhub image link

docker run --rm -p 8000:8000 mahyarkarimi/ffmpeg-ms:0.1.1-alpine

Deploy with docker-compose.yml


version: '3'

services:
    api:
        image: mahyarkarimi/ffmpeg-ms:0.1.1-alpine
        restart: unless-stopped
        ports:
            - 8000:8000
        volumes:
            - ./.htpasswd:/app/.htpasswd

Features


  1. Convert any media with given ffmpeg style output format.
  2. Stream output from /convert endpoint.
  3. File based download from /convert-file endpoint.
  4. Has rate limit for calling each endpoint based on user (default 5 requests per minute).
  5. Can have basic authentication based on /app/.htpasswd file generated by htpasswd of apache2-utils. password must be encrypted with the bcrypt algorithm.

Generate .htpasswd file


In order to activate authentication, generate .htpasswd file using apache2-utils. Install apache2-utils on debian/ubuntu:

sudo apt-get install apache2-utils

To create user run the following command in terminal (replace <username> and <password> with your desired credentials):

htpasswd -B -cb .htpasswd <username> <password> 

API Documentation


FFMPEG file conversion microservice API documentation

Version: 0.1.1

Contact information:
[email protected]

License: MIT

/convert

POST

Summary

Convert a media file (video or audio) and get response as stream

Description

Convert a media file and return as stream

Parameters
Name Located in Description Required Schema
input_options query No string
output_options query Yes string
buffer_size query No integer
Responses
Code Description
200 Successful operation
413 file to convert is larger than upload size limit
422 Unprocessable entity when either file in body or action in query parameters is not available

/convert-file

POST

Summary

Convert a media file (video or audio) and get response as file

Description

Convert a media file and return as file

Parameters
Name Located in Description Required Schema
input_options query No string
output_options query Yes string
Responses
Code Description
200 Successful operation
413 file to convert is larger than upload size limit
422 Unprocessable entity when either file in body or action in query parameters is not available