-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from klahaha/tests
Some refactoring
- Loading branch information
Showing
51 changed files
with
892 additions
and
815 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
bin/ | ||
streams.yaml | ||
config.yml | ||
config.yaml | ||
go-transcode | ||
bin | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,65 @@ | ||
# Go live HTTP on-demand transcoding | ||
Transcoding is expensive and resource consuming operation on CPU and GPU. For big companies with thousands of customers it is essential, to have a dedicated 24/7 transcoding servers. But we, single sporadic users of transcoding, need to have different approach. Transcoding should be done only when its output is really needed. This tool is trying to solve this problem by offering transcoding on demand. | ||
# go-transcode HTTP on-demand transcoding API | ||
|
||
This tool is intended to be used with live streams only. Seeking is not supported, yet. | ||
## Why | ||
|
||
Transcoding is expensive and resource consuming operation on CPU and GPU. For big companies with thousands of customers it is essential, to have a dedicated 24/7 transcoding servers which can store all the transcoded versions. | ||
|
||
For the rest of us who don't have infinite resources and cannot have 3 times bigger media library because of transcoding, we should only transcode when it is needed. This tool is trying to solve this problem by offering transcoding on demand. | ||
|
||
This feature is common in media centers (plex, jellyfin) but there was no simple transcoding server without all other media center features. Now there is one! go-transcode is simple and extensible, and will probably not add features unrelated to transcoding. | ||
|
||
## Features | ||
|
||
Sources: | ||
- [x] Live streams | ||
- [ ] Static files (basic support) | ||
- [x] Any codec/container supported by ffmpeg | ||
|
||
Outputs: | ||
- [x] Basic MP4 over HTTP (h264+aac) : `http://go-transcode/[profile]/[stream-id]` | ||
- [x] Basic HLS over HTTP (h264+aac) : `http://go-transcode/[profile]/[stream-id]/index.m3u8` | ||
- [x] Demo HTML player (for HLS) : `http://go-transcode/[profile]/[stream-id]/play.html` | ||
|
||
Features: | ||
- [ ] Seeking for static files (index) | ||
- [ ] Audio/Subtitles tracks | ||
- [ ] Private mode (serve users authenticated by reverse proxy) | ||
|
||
## Config | ||
Specify streams as object in yaml file. | ||
|
||
### Streams | ||
Create `streams.yaml` file, with your streams: | ||
Place your config file in `./config.yaml` (or `/etc/transcode/config.yaml`). The streams are defined like this: | ||
|
||
```yaml | ||
streams: | ||
<stream-id>: <stream-url> | ||
``` | ||
Example: | ||
Full configuration example: | ||
```yaml | ||
# allow debug outputs | ||
debug: true | ||
|
||
# bind server to IP:PORT (use :8888 for all connections) | ||
bind: localhost:8888 | ||
|
||
# serve static files from this directory (optional) | ||
static: /var/www/html | ||
|
||
# TODO: issue #4 | ||
proxy: true | ||
|
||
streams: | ||
cam: rtmp://localhost/live/cam | ||
ch1_hd: http://192.168.1.34:9981/stream/channelid/85 | ||
ch2_hd: http://192.168.1.34:9981/stream/channelid/43 | ||
``` | ||
HTTP streaming is accessible via: | ||
- `http://localhost:8080/<profile>/<stream-id>` | ||
|
||
HLS is accessible via: | ||
- `http://localhost:8080/<profile>/<stream-id>/index.m3u8` | ||
- `http://localhost:8080/<profile>/<stream-id>/play.html` | ||
|
||
## CPU Profiles | ||
Profiles (HTTP and HLS) with CPU transcoding can be found in `profiles`: | ||
## Transcoding profiles | ||
* h264_360p | ||
* h264_540p | ||
* h264_720p | ||
* h264_1080p | ||
go-transcode supports any formats that ffmpeg likes. We provide profiles out-of-the-box for h264+aac (mp4 container) for 360p, 540p, 720p and 1080p resolutions: `h264_360p`, `h264_540p`, `h264_720p` and `h264_1080p`. Profiles can have any name, but must match regex: `^[0-9A-Za-z_-]+$` | ||
|
||
Profile names must match flowing regex: `^[0-9A-Za-z_-]+$` | ||
|
||
## GPU Profiles | ||
Profiles (HTTP and HLS) with GPU transcoding can be found in `profiles_nvidia`: | ||
|
||
* h264_360p | ||
* h264_540p | ||
* h264_720p | ||
* h264_1080p | ||
|
||
Profile names must match flowing regex: `^[0-9A-Za-z_-]+$` | ||
In these profile directories, actual profiles are located in `hls/` and `http/`, depending on the output format requested. The profiles scripts detect hardware support by running ffmpeg. No special config needed to use hardware acceleration. | ||
|
||
## Docker | ||
|
||
|
@@ -63,7 +75,7 @@ docker build -t go-transcode:latest . | |
docker run --rm -d \ | ||
--name="go-transcode" \ | ||
-p "8080:8080" \ | ||
-v "${PWD}/streams.yaml:/app/streams.yaml" go-transcode:latest | ||
-v "${PWD}/config.yaml:/app/config.yaml" go-transcode:latest | ||
``` | ||
|
||
## Nvidia GPU support (docker) | ||
|
@@ -85,7 +97,7 @@ docker run --rm -d \ | |
--gpus=all \ | ||
--name="go-transcode-nvidia" \ | ||
-p "8080:8080" \ | ||
-v "${PWD}/streams.yaml:/app/streams.yaml" go-transcode-nvidia:latest | ||
-v "${PWD}/config.yaml:/app/config.yaml" go-transcode-nvidia:latest | ||
``` | ||
|
||
### Supported inputs | ||
|
@@ -103,3 +115,34 @@ Input codec will be automatically determined from given stream. Please check you | |
| vc1 | vc1_cuvid | SMPTE VC-1 | | ||
| vp8 | vp8_cuvid | On2 VP8 | | ||
| vp9 | vp9_cuvid | Google VP9 | | ||
|
||
## Alternatives | ||
|
||
- [nginx-vod-module](https://github.com/kaltura/nginx-vod-module): Only supports MP4 sources. | ||
- [tvheadend](https://tvheadend.org/): Intended for various live sources (IPTV or DVB), not media library - although it can record TV. Supports Nvidia acceleration, but it is hard to compile. | ||
- [jellyfin](https://github.com/jellyfin/jellyfin): Supports live TV sources, although does not work realiably. Cannot run standalone transcoding service (without media library). | ||
- Any suggestions? | ||
|
||
## Contribute | ||
|
||
Join us in the [Matrix space](https://matrix.to/#/#go-transcode:proxychat.net) (or the [#go-transcode-general](https://matrix.to/#/#go-transcode-general:proxychat.net) room directly) or [via XMPP bridge](xmpp:#go-transcode-general#[email protected]). | ||
|
||
## Architecture | ||
|
||
The source code is in the following files/folders: | ||
|
||
- `cmd/` and `main.go`: source for the command-line interface | ||
- `hls/`: process runner for HLS transcoding | ||
- `internal/`: actual source code logic | ||
|
||
*TODO: document different modules/packages and dependencies* | ||
|
||
Other files/folders in the repositories are: | ||
|
||
- `data/`: files used/served by go-transcode | ||
- `dev/`: some docker helper scripts | ||
- `profiles/`: the ffmpeg profiles for transcoding | ||
- `tests/`: some tests for the project | ||
- `Dockerfile`, `Dockerfile.nvidia` and `docker-compose.yaml`: for the docker lovers | ||
- `god.mod` and `go.sum`: golang dependencies/modules tracking | ||
- `LICENSE`: licensing information (Apache 2.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.