项目作者: fzakaria

项目描述 :
A basic transcoding Golang server that utilizes FFMPEG over the command line
高级语言: Go
项目地址: git://github.com/fzakaria/transcoding.git
创建时间: 2016-01-24T10:06:54Z
项目社区:https://github.com/fzakaria/transcoding

开源协议:

下载


Transcoding Server tool

Sample Commands

  1. brew install ffmpeg
  2. go get github.com/fzakaria/transcoding
  3. go install github.com/fzakaria/transcoding
  4. #Assumes $GOPATH/bin is on your $PATH
  5. transcoding --config ./configs/prod-us-east-1.toml

Server

A basic server implementation is included that offers the facility to transcode uploaded multipart files and some additional admin urls.

  1. GET /transcode
  2. POST /transcode
  3. #Some admin routes
  4. GET /admin
  5. GET /admin/ping
  6. GET /admin/pprof/
  7. GET /admin/pprof/heap
  8. GET /admin/pprof/goroutine
  9. GET /admin/pprof/block
  10. GET /admin/pprof/threadcreate
  11. GET /admin/pprof/cmdline
  12. GET /admin/pprof/profile
  13. GET /admin/pprof/symbol
  14. GET /admin/stats
  15. GET /admin/config

Transcoding

A useful route is the [POST|GET] /transcode one, which provided a file and conversion type will return the resulting MP4 file. A sample form is provided at the GET route, however you can also make use of CLI tools.

  1. brew install http
  2. http -f POST http://localhost:8080/transcode input@~/Downloads/sample.mp4 type=480p > output.mp4

AWS

The server has a tighter integration with performing Transcoding from files saved in S3 and writting them back out to S3.
The route available is POST /api/transcode

You can specify a samlpe request based on the following schema:

  1. {
  2. "input": {
  3. "bucket": "slinger-test",
  4. "key": "input.mp4"
  5. },
  6. "output": {
  7. "bucket": "slinger-test",
  8. "key": "output.mp4"
  9. },
  10. "type" : "320p"
  11. }

THE SERVER MUST HAVE ACCESS TO THE INPUT & OUTPUT BUCKET - SEE AWS BUCKET POLICIES

Docker

To make bootstrapping easier for variety of platforms. A Dockerfile is provided which will run the server in a docker container.

  1. #The following commands assumes you are in the package
  2. docker build -t transcode-server .
  3. docker run -p 8080:8080 transcode-server
  4. #You can now access the server at localhost:8080
  5. #or if you ar on mac osx `docker-machine ip default`

Choosing an appriorate filter description

A common scenario is re-encoding a video for streaming over the web. In such a scenario you generally want to transcode to a lower resolution and bitrate.

Resolution

Resolution is the “sharpness” of the video in question.
Filesize is not determined by resolution

filesize (in MB) = (bitrate in Mbit/s 8) (video length in seconds)
But a larger resolution will require more bitrate for it to keep the same level of “quality”

According to this post here are some general resolution/bitrate guidelines.

Resolution Bitrate Approx. File size of 10 minutes
320p (mobile) 180 kbit/s ~13 MB
360p 300 kbit/s ~22MB
480p 500 kbit/s ~37MB
576p (PAL) 850 kbit/s ~63MB
720p 1000 kbit/s ~75 MB