{"id":13581494,"url":"https://github.com/m1k1o/go-transcode","last_synced_at":"2025-04-12T16:38:54.929Z","repository":{"id":41496728,"uuid":"322725571","full_name":"m1k1o/go-transcode","owner":"m1k1o","description":"On-demand transcoding origin server for live inputs and static files in Go using ffmpeg. Also with NVIDIA GPU hardware acceleration.","archived":false,"fork":false,"pushed_at":"2024-12-31T15:52:59.000Z","size":302,"stargazers_count":243,"open_issues_count":22,"forks_count":41,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-03T17:13:36.996Z","etag":null,"topics":["demand-transcoding","docker","ffmpeg","golang","gpu","live-streaming","nvidia-cuda","streams","transcoding"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m1k1o.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["m1k1o"]}},"created_at":"2020-12-18T23:18:53.000Z","updated_at":"2025-03-29T17:35:16.000Z","dependencies_parsed_at":"2024-03-11T19:25:52.125Z","dependency_job_id":"20cb6e4b-2aa6-40cf-8057-cc5e8977ac2b","html_url":"https://github.com/m1k1o/go-transcode","commit_stats":{"total_commits":259,"total_committers":8,"mean_commits":32.375,"dds":"0.20463320463320467","last_synced_commit":"6f49701823737f0ae0ba510334d390cfa0d45f8c"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1k1o%2Fgo-transcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1k1o%2Fgo-transcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1k1o%2Fgo-transcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m1k1o%2Fgo-transcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m1k1o","download_url":"https://codeload.github.com/m1k1o/go-transcode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248597936,"owners_count":21130983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demand-transcoding","docker","ffmpeg","golang","gpu","live-streaming","nvidia-cuda","streams","transcoding"],"created_at":"2024-08-01T15:02:03.423Z","updated_at":"2025-04-12T16:38:54.911Z","avatar_url":"https://github.com/m1k1o.png","language":"Go","funding_links":["https://github.com/sponsors/m1k1o"],"categories":["Go","HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# go-transcode HTTP on-demand transcoding API\n\nOn demand transcoding of live sources and static files (with seeking).\n\n## Why\n\nTranscoding 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.\n\nFor 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.\n\nThis 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.\n\n## Features\n\nSources:\n- [x] Live streams\n- [x] VOD (static files, basic support)\n- [x] Any codec/container supported by ffmpeg\n\nLive Outputs:\n- [x] Basic MP4 over HTTP (h264+aac) : `http://go-transcode/[profile]/[stream-id]`\n- [x] Basic HLS over HTTP (h264+aac) : `http://go-transcode/[profile]/[stream-id]/index.m3u8`\n- [x] Demo HTML player (for HLS) : `http://go-transcode/[profile]/[stream-id]/play.html`\n- [x] HLS proxy : `http://go-transcode/hlsproxy/[hls-proxy-id]/[original-request]`\n\nVOD Outputs:\n- [x] HLS master playlist (h264+aac) : `http://go-transcode/vod/[media-path]/index.m3u8`\n- [x] HLS custom profile (h264+aac) : `http://go-transcode/vod/[media-path]/[profile].m3u8`\n- [x] Demo HTML player (for master playlist) : `http://go-transcode/vod/[media-path]/play.html`\n\nFeatures:\n- [x] Seeking for static files (indexed vod files)\n- [ ] Audio/Subtitles tracks\n- [ ] Private mode (serve users authenticated by reverse proxy)\n\nYou can find examples in [docs](./docs).\n\n## Config\n\nPlace your config file in `./config.yaml` (or `/etc/transcode/config.yaml`). The streams are defined like this:\n\n```yaml\nstreams:\n  \u003cstream-id\u003e: \u003cstream-url\u003e\n```\n\nFull configuration example:\n\n```yaml\n# allow debug outputs\ndebug: true\n\n# mount debug pprof endpoint at /debug/pprof/\npprof: true\n\n# bind server to IP:PORT (use :8888 for all connections)\nbind: localhost:8888\n\n# serve static files from this directory (optional)\nstatic: /var/www/html\n\n# X-Forwarded-For headers will be used to determine the client IP\nproxy: true\n\n# allow CORS requests (for web players)\ncors: true\n\n# For live streaming\nstreams:\n  cam: rtmp://localhost/live/cam\n  ch1_hd: http://192.168.1.34:9981/stream/channelid/85\n  ch2_hd: http://192.168.1.34:9981/stream/channelid/43\n\n# To import channels from enigma2\nenigma2:\n  # address of your enigma2 device (if using password, use http://user:pass@host:port)\n  webif-url: http://192.168.1.10/\n  # (optional) address of your enigma2 stream server, if empty, webif-url will be used with port 8001\n  stream-url: http://192.168.1.10:8001/\n  # name of the bouquet to import channels from\n  bouquet: \"SKY Germany HD\"\n  # reference to the bouquet to import channels from (use instead of bouquet name)\n  reference: \"1:7:1:0:0:0:0:0:0:0:FROM BOUQUET \"userbouquet.dbe0e.tv\" ORDER BY bouquet\"\n\n# For static files\nvod:\n  # Source, where are static files, that will be transcoded\n  media-dir: ./media\n  # Temporary transcode output directory, if empty, default tmp folder will be used\n  transcode-dir: ./transcode\n  # Available video profiles\n  video-profiles:\n    360p:\n      width: 640 # px\n      height: 360 # px\n      bitrate: 800 # kbps\n    540p:\n      width: 960\n      height: 540\n      bitrate: 1800\n    720p:\n      width: 1280\n      height: 720\n      bitrate: 2800\n    1080p:\n      width: 1920\n      height: 1080\n      bitrate: 5000\n  # Use video keyframes as existing reference for chunks split\n  # Using this might cause long probing times in order to get\n  # all keyframes - therefore they should be cached\n  video-keyframes: false\n  # Single audio profile used\n  audio-profile:\n    bitrate: 192 # kbps\n  # If cache is enabled\n  cache: true\n  # If dir is empty, cache will be stored in the same directory as media source\n  # If not empty, cache files will be saved to specified directory\n  cache-dir: ./cache\n  # OPTIONAL: Use custom ffmpeg \u0026 ffprobe binary paths\n  ffmpeg-binary: ffmpeg\n  ffprobe-binary: ffprobe\n\n# For proxying HLS streams\nhls-proxy:\n  my_server: http://192.168.1.34:9981\n```\n\n## Transcoding profiles for live streams\n\ngo-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_-]+$`\n\nIn 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.\n\n## Install\n\nClone repository and build with go compiler:\n\n```sh\n$ git clone https://github.com/m1k1o/go-transcode\n$ cd go-transcode\n$ go build\n$ ./go-transcode serve\n3:58PM WRN preflight complete without config file debug=false\n3:56PM INF starting main server service=main\n3:56PM INF http listening on 127.0.0.1:8080 module=http\n3:56PM INF serving streams from basedir /home/klahaha/go-transcode: map[] service=main\n3:56PM INF main ready service=main\n```\n\nFirst 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.\n\n## Docker\n\n### Build\n\n```sh\ndocker build -t go-transcode:latest .\n```\n\n### Run\n\n```sh\ndocker run --rm -d \\\n  --name=\"go-transcode\" \\\n  -p \"8080:8080\" \\\n  -v \"${PWD}/config.yaml:/app/config.yaml\" go-transcode:latest\n```\n\n## VAAPI Support (docker)\n\n```sh\ndocker run --rm -d \\\n  --name=\"go-transcode\" \\\n  --device=/dev/dri:/dev/dri \\\n  -p \"8080:8080\" \\\n  -v \"${PWD}/config.yaml:/app/config.yaml\" go-transcode:latest\n```\n\n## VDPAU Support (docker)\n\nTo use VDPAU, you need to build the image with `--build-arg VDPAU=1`.\n\n## Nvidia GPU support (docker)\n\nYou will need to have [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) installed.\n\n### Build\n\nFirst, you need to build previous container. Then, build Nvidia container.\n\n```sh\ndocker build --build-arg \"TRANSCODE_IMAGE=go-transcode:latest\" -t go-transcode-nvidia:latest -f Dockerfile.nvidia .\n```\n\n### Run\n\n```sh\ndocker run --rm -d \\\n  --gpus=all \\\n  --name=\"go-transcode-nvidia\" \\\n  -p \"8080:8080\" \\\n  -v \"${PWD}/config.yaml:/app/config.yaml\" go-transcode-nvidia:latest\n```\n\n### Supported inputs\n\nInput 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).\n\n| Codec      | CUVID       | Codec Name                                |\n| ---------- | ----------- | ----------------------------------------- |\n| h264       | h264_cuvid  | H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 |\n| hevc       | hevc_cuvid  | H.265 / HEVC                              |\n| mjpeg      | mjpeg_cuvid | Motion JPEG                               |\n| mpeg1video | mpeg1_cuvid | MPEG-1 video                              |\n| mpeg2video | mpeg2_cuvid | MPEG-2 video                              |\n| mpeg4      | mpeg4_cuvid | MPEG-4 part 2                             |\n| vc1        | vc1_cuvid   | SMPTE VC-1                                |\n| vp8        | vp8_cuvid   | On2 VP8                                   |\n| vp9        | vp9_cuvid   | Google VP9                                |\n\n## Alternatives\n\n- [nginx-vod-module](https://github.com/kaltura/nginx-vod-module): Only supports MP4 sources.\n- [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.\n- [jellyfin](https://github.com/jellyfin/jellyfin): Supports live TV sources, although does not work realiably. Cannot run standalone transcoding service (without media library).\n- Any suggestions?\n\n## Contribute\n\nJoin 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#proxychat.net@matrix.org).\n\n## Architecture\n\nThe source code is in the following files/folders:\n\n- `cmd/` and `main.go`: source for the command-line interface\n- `hls/`: process runner for HLS transcoding\n- `hlsvod/`: process runner for HLS VOD transcoding (for static files)\n- `internal/`: actual source code logic\n\n*TODO: document different modules/packages and dependencies*\n\nOther files/folders in the repositories are:\n\n- `data/`: files used/served by go-transcode\n- `dev/`: some docker helper scripts\n- `profiles/`: the ffmpeg profiles for transcoding\n- `tests/`: some tests for the project\n- `Dockerfile`, `Dockerfile.nvidia` and `docker-compose.yaml`: for the docker lovers\n- `god.mod` and `go.sum`: golang dependencies/modules tracking\n- `LICENSE`: licensing information (Apache 2.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1k1o%2Fgo-transcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm1k1o%2Fgo-transcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm1k1o%2Fgo-transcode/lists"}