Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 #30

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft

V1 #30

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
File renamed without changes.
File renamed without changes.
64 changes: 64 additions & 0 deletions .docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Docker

## Build

```sh
./build go-transcode:latest
```

## Run

```sh
docker run --rm -d \
--name="go-transcode" \
-p "8080:8080" \
-v "${PWD}/config.yaml:/app/config.yaml" go-transcode:latest
```

# VAAPI Support

```sh
docker run --rm -d \
--name="go-transcode" \
--device=/dev/dri:/dev/dri \
-p "8080:8080" \
-v "${PWD}/config.yaml:/app/config.yaml" go-transcode:latest
```

# Nvidia GPU support

You will need to have [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) installed.

## Build

First, you need to build previous container. Then, build Nvidia container.

```sh
docker build --build-arg "TRANSCODE_IMAGE=go-transcode:latest" -t go-transcode-nvidia:latest -f Dockerfile.nvidia ..
```

## Run

```sh
docker run --rm -d \
--gpus=all \
--name="go-transcode-nvidia" \
-p "8080:8080" \
-v "${PWD}/config.yaml:/app/config.yaml" go-transcode-nvidia:latest
```

## Supported inputs

Input codec will be automatically determined from given stream. Please check your graphic card's supported codec and maximum concurrent sessions [here](https://developer.nvidia.com/video-encode-decode-gpu-support-matrix).

| Codec | CUVID | Codec Name |
| ---------- | ----------- | ----------------------------------------- |
| h264 | h264_cuvid | H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 |
| hevc | hevc_cuvid | H.265 / HEVC |
| mjpeg | mjpeg_cuvid | Motion JPEG |
| mpeg1video | mpeg1_cuvid | MPEG-1 video |
| mpeg2video | mpeg2_cuvid | MPEG-2 video |
| mpeg4 | mpeg4_cuvid | MPEG-4 part 2 |
| vc1 | vc1_cuvid | SMPTE VC-1 |
| vp8 | vp8_cuvid | On2 VP8 |
| vp9 | vp9_cuvid | Google VP9 |
5 changes: 5 additions & 0 deletions .docker/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
cd "$(dirname "$0")"

BUILD_TAG="${1:-transcode_server_img}"
docker build -t "${BUILD_TAG}" -f Dockerfile ..
10 changes: 5 additions & 5 deletions docker-compose.yaml → .docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ version: "3"

services:
go-transcode:
build: .
container_name: go-transcode
restart: unless-stopped
build: "./"
container_name: "go-transcode"
restart: "unless-stopped"
ports:
- "8080:8080"
volumes:
- ./config.yaml:/app/config.yaml
- "./config.yaml:/app/config.yaml"
# Mount your VOD here, for hlsvod module
# - ./media:/app/media
command: serve -d
command: "serve -d"
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build:
variables:
BASE_IMAGE: $CI_REGISTRY_IMAGE:latest
script:
- docker build -t $BASE_IMAGE .
- docker build -t $BASE_IMAGE -f ./docker/Dockerfile .
- docker push $BASE_IMAGE
only:
- master
Expand All @@ -25,7 +25,7 @@ build nivdia:
GO_TRANSCODE_IMAGE: $CI_REGISTRY_IMAGE:latest
IMAGE_TAG: $CI_REGISTRY_IMAGE/nivdia:latest
script:
- docker build --build-arg "GO_TRANSCODE_IMAGE=${GO_TRANSCODE_IMAGE}" --build-arg "BASE_IMAGE=${NVIDIA_FFMPEG_IMAGE}" -t $IMAGE_TAG -f Dockerfile.nvidia .
- docker build --build-arg "GO_TRANSCODE_IMAGE=${GO_TRANSCODE_IMAGE}" --build-arg "BASE_IMAGE=${NVIDIA_FFMPEG_IMAGE}" -t $IMAGE_TAG -f ./docker/Dockerfile.nvidia .
- docker push $IMAGE_TAG
only:
- master
97 changes: 15 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,18 @@ streams:
Full configuration example:

```yaml
# allow debug outputs
debug: true

# mount debug pprof endpoint at /debug/pprof/
pprof: 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
# trust reverse proxies
proxy: true

# mount debug pprof endpoint at /debug/pprof/
pprof: true

# For live streaming
streams:
cam: rtmp://localhost/live/cam
Expand Down Expand Up @@ -136,70 +133,7 @@ $ ./go-transcode serve

First line is warning and "serving streams" line says empty list (`map[]`) because we don't have config.yaml so there no stream configured. Make your config.yaml and try again.

## Docker

### Build

```sh
docker build -t go-transcode:latest .
```

### Run

```sh
docker run --rm -d \
--name="go-transcode" \
-p "8080:8080" \
-v "${PWD}/config.yaml:/app/config.yaml" go-transcode:latest
```

## VAAPI Support (docker)

```sh
docker run --rm -d \
--name="go-transcode" \
--device=/dev/dri:/dev/dri \
-p "8080:8080" \
-v "${PWD}/config.yaml:/app/config.yaml" go-transcode:latest
```

## Nvidia GPU support (docker)

You will need to have [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) installed.

### Build

First, you need to build previous container. Then, build Nvidia container.

```sh
docker build --build-arg "TRANSCODE_IMAGE=go-transcode:latest" -t go-transcode-nvidia:latest -f Dockerfile.nvidia .
```

### Run

```sh
docker run --rm -d \
--gpus=all \
--name="go-transcode-nvidia" \
-p "8080:8080" \
-v "${PWD}/config.yaml:/app/config.yaml" go-transcode-nvidia:latest
```

### Supported inputs

Input codec will be automatically determined from given stream. Please check your graphic card's supported codec and maximum concurrent sessions [here](https://developer.nvidia.com/video-encode-decode-gpu-support-matrix).

| Codec | CUVID | Codec Name |
| ---------- | ----------- | ----------------------------------------- |
| h264 | h264_cuvid | H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 |
| hevc | hevc_cuvid | H.265 / HEVC |
| mjpeg | mjpeg_cuvid | Motion JPEG |
| mpeg1video | mpeg1_cuvid | MPEG-1 video |
| mpeg2video | mpeg2_cuvid | MPEG-2 video |
| mpeg4 | mpeg4_cuvid | MPEG-4 part 2 |
| vc1 | vc1_cuvid | SMPTE VC-1 |
| vp8 | vp8_cuvid | On2 VP8 |
| vp9 | vp9_cuvid | Google VP9 |
See [.docker](.docker) folder for docker support.

## Alternatives

Expand All @@ -216,19 +150,18 @@ Join us in the [Matrix space](https://matrix.to/#/#go-transcode:proxychat.net) (

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
- `hlsvod/`: process runner for HLS VOD transcoding (for static files)
- `internal/`: actual source code logic
- `.docker`: for docker support.
- `cmd/` and `main.go`: source for the command-line interface.
- `internal/`: internal source code.
- `modules/`: standalone plug'n'play modules.
- `pkg/`: external packages ready to be reused.

*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)
- `docs/`: documentation and usage examples.
- `profiles/`: the ffmpeg profiles for transcoding.
- `tests/`: some tests for the project.
- `god.mod` and `go.sum`: golang dependencies/modules tracking.
- `LICENSE`: licensing information (Apache 2.0).