{"id":13618152,"url":"https://github.com/aperim/docker-nvidia-cuda-ffmpeg","last_synced_at":"2025-12-25T02:31:45.384Z","repository":{"id":59449268,"uuid":"537337600","full_name":"aperim/docker-nvidia-cuda-ffmpeg","owner":"aperim","description":"A docker container, with ffmpeg that supports scale_cuda among other things","archived":false,"fork":false,"pushed_at":"2024-08-13T08:04:39.000Z","size":148,"stargazers_count":11,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-08T03:36:36.625Z","etag":null,"topics":["cuda","ffmpeg","gpu","hacktoberfest","nvidia"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","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/aperim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-16T06:42:50.000Z","updated_at":"2024-03-12T08:12:31.000Z","dependencies_parsed_at":"2023-02-12T14:46:51.080Z","dependency_job_id":"933d2099-913b-4173-95d2-8109c67c2f8c","html_url":"https://github.com/aperim/docker-nvidia-cuda-ffmpeg","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aperim%2Fdocker-nvidia-cuda-ffmpeg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aperim%2Fdocker-nvidia-cuda-ffmpeg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aperim%2Fdocker-nvidia-cuda-ffmpeg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aperim%2Fdocker-nvidia-cuda-ffmpeg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aperim","download_url":"https://codeload.github.com/aperim/docker-nvidia-cuda-ffmpeg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248862598,"owners_count":21173837,"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":["cuda","ffmpeg","gpu","hacktoberfest","nvidia"],"created_at":"2024-08-01T20:01:55.307Z","updated_at":"2025-12-25T02:31:45.349Z","avatar_url":"https://github.com/aperim.png","language":"Dockerfile","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# docker-nvidia-cuda-ffmpeg\nA docker container, with ffmpeg that supports scale_cuda among other things\n\n## Options\n\nTo see the options for specific filters use:\n\n### scale_cuda\n\n```bash\ndocker run -it --rm --gpus=all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all ghcr.io/aperim/nvidia-cuda-ffmpeg:latest -h filter=scale_cuda\n```\n\n### overlay_cuda\n\n```bash\ndocker run -it --rm --gpus=all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all ghcr.io/aperim/nvidia-cuda-ffmpeg:latest -h filter=overlay_cuda\n```\n\n### hevc_nvenc\n\n```bash\ndocker run -it --rm --gpus=all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all ghcr.io/aperim/nvidia-cuda-ffmpeg:latest -h encoder=hevc_nvenc\n```\n\n### h264_nvenc\n\n```bash\ndocker run -it --rm --gpus=all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all ghcr.io/aperim/nvidia-cuda-ffmpeg:latest -h encoder=h264_nvenc\n```\n\n## Getting it working\n\nThe NVIDIA CUDA drivers are badly broken. To get encoding/decoding working currently - you must apply a patch/hack by [keylase](https://github.com/keylase/nvidia-patch)\n\nMore information [here](https://github.com/NVIDIA/open-gpu-kernel-modules/issues/104#issuecomment-1246276388)\n\n```bash\n# Ensure secure boot is disabled - ie mokutil --disable-validation\nsudo systemctl stop docker\nsudo apt-get -y remove nvidia-docker2 # If you are using it\nsudo apt-get -y install build-essential curl dkms linux-headers-$(uname -r)\nsudo rm -f /etc/modprobe.d/blacklist-nvidia-nouveau.conf /etc/modprobe.d/nvidia-unsupported-gpu.conf\necho blacklist nouveau | sudo tee /etc/modprobe.d/blacklist-nvidia-nouveau.conf \u0026\u0026 \\\n\techo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/blacklist-nvidia-nouveau.conf \u0026\u0026 \\\n\techo options nvidia NVreg_OpenRmEnableUnsupportedGpus=1 | sudo tee /etc/modprobe.d/nvidia-unsupported-gpu.conf \u0026\u0026 \\\n\tsudo update-initramfs -u \u0026\u0026 \\\n\tsudo /sbin/reboot\ngit clone https://github.com/keylase/nvidia-patch.git \u0026\u0026 \\\n\tcurl -LO https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run \u0026\u0026 \\\n\tchmod +x ./cuda_11.7.1_515.65.01_linux.run \u0026\u0026 \\\n\tsudo ./cuda_11.7.1_515.65.01_linux.run -m=kernel-open\nsudo /sbin/reboot\n# Confirm working\nnvidia-smi\ncd nvidia-patch\nsudo bash ./patch.sh\ncd ..\nrm -Rf ./nvidia-patch ./cuda_*.run\nsudo /sbin/reboot\n# Check can encode now\ncurl -LO http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4\nffmpeg -i BigBuckBunny.mp4 -c:v h264_nvenc  output.mp4\n```\n\n## Extras\n\n[**Mosaic**](#Mosaic)\nGenerate a video mosaic using overlays. Easily create 4, 6 and 9 input mosaics.\n\n[**Camera**](#Camera)\nShortcut for transcoding rtsp camera streams.\n\n### Mosaic\n\nGenerate a 4, 6 or 9 panel mosaic / overlay.\n\nYou can use the mosaic command to generate the ffmpeg command you need, or just let it generate the mosaic and stream it for you.\n\nJust pass the environment variables (details below) and use a command of `mosaic`\n\n#### Required environment variables\n\n| Variable                 | Use                                  | Default                                | Notes                                                                                                                                |\n|--------------------------|--------------------------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| INPUT0                   | The background image.                | / etc / mosaic / 1920x1080-black.png   | The default is a black png that ships with the container                                                                             |\n| INPUT1                   | The first panel URL                  | /etc/mosaic/1920x1080.png              | Supply anything ffmpeg can process                                                                                                   |\n| INPUT2                   | The second panel URL                 | \"                                      | \"                                                                                                                                    |\n| INPUT3                   | The third panel URL                  | \"                                      | \"                                                                                                                                    |\n| INPUT4                   | The forth panel URL                  | \"                                      | \"                                                                                                                                    |\n| INPUT5                   | The fifth panel URL                  | \"                                      | Only supply these if you are using a 6 panel mosaic                                                                                  |\n| INPUT6                   | The sixth panel URL                  | \"                                      | \"                                                                                                                                    |\n| INPUT7                   | The seventh panel URL                | \"                                      | Only supply these if you are using a 9 panel mosaic                                                                                  |\n| INPUT8                   | The eight panel URL                  | \"                                      | \"                                                                                                                                    |\n| INPUT9                   | The night panel URL                  | \"                                      | \"                                                                                                                                    |\n| CONTAINER                | The output container                 | mpegts                                 | passed to -f ie `-f mpegts` or `-f flv`                                                                                              |\n| OUTPUT                   | The output destination               | udp://224.0.51.1:1234?pkt_size=188     | Where the data should go                                                                                                             |\n| BITRATE                  | The output bitrate                   | 8M                                     |                                                                                                                                      |\n| ENCODER                  | The encoder to use                   | hevc                                   | h264 or hevc                                                                                                                         |\n| ENCODE_PRESET            | The encoder preset                   | veryfast                               |                                                                                                                                      |\n| RESOLUTION               | Select from a list of defaults       | FHD                                    | Select nHD,qHD,HD,HD+,FHD,DCI 2K,QHD,QHD+,4K UHD to auto set width and height                                                        |\n| WIDTH                    | The output mosaic width              | 1920                                   |                                                                                                                                      |\n| HEIGHT                   | The output mosaic height             | 1080                                   |                                                                                                                                      |\n| FFMPEG_THREAD_QUEUE_SIZE | Thread queue size                    | 512                                    | Tweak this only if you need                                                                                                          |\n| FFMPEG_CUDA_FORMAT       | The format inside cuda processing    | nv12                                   | Tweak this only if you need                                                                                                          |\n| GENCMD                   | Generate the ffmpeg command if not 0 | 0                                      | Set this to `1` to generate an example command with your settings so that you can tweak it as you desire and run the mosaic yourself |\n\n#### Example Docker Compose\n\n```yaml\n---\nversion: '3.8'\n\nservices:\n  ffmpeg:\n    image: ghcr.io/aperim/nvidia-cuda-ffmpeg:latest\n    deploy:\n      resources:\n        reservations:\n          devices:\n            - driver: nvidia\n              count: 1\n              capabilities: [gpu]\n    restart: unless-stopped              \n    environment:\n      PUID: 1000\n      PGID: 1000\n      TZ: Australia/Sydney\n      NVIDIA_VISIBLE_DEVICES: all\n      NVIDIA_DRIVER_CAPABILITIES: all\n      NVIDIA_REQUIRE_CUDA: cuda\u003e=11.4\n      INPUT1: https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8\n      INPUT2: https://d3rlna7iyyu8wu.cloudfront.net/skip_armstrong/skip_armstrong_multichannel_subs.m3u8\n      INPUT3: http://amssamples.streaming.mediaservices.windows.net/634cd01c-6822-4630-8444-8dd6279f94c6/CaminandesLlamaDrama4K.ism/manifest(format=m3u8-aapl)\n      INPUT4: https://devimages.apple.com.edgekey.net/iphone/samples/bipbop/bipbopall.m3u8\n    volumes:\n      - \"/etc/timezone:/etc/timezone:ro\"\n      - \"/etc/localtime:/etc/localtime:ro\"\n    command: mosaic\n\n```\n\n#### Example To Generate Your Own Command\n\nRunning the command below:\n\n```bash\ndocker run -it --rm \\\n    -e GENCMD=1 \\\n    -e INPUT1=https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8 \\\n    -e INPUT2=https://d3rlna7iyyu8wu.cloudfront.net/skip_armstrong/skip_armstrong_multichannel_subs.m3u8 \\\n    -e INPUT3=http://amssamples.streaming.mediaservices.windows.net/634cd01c-6822-4630-8444-8dd6279f94c6/CaminandesLlamaDrama4K.ism/manifest\\(format=m3u8-aapl\\) \\\n    -e INPUT4=https://devimages.apple.com.edgekey.net/iphone/samples/bipbop/bipbopall.m3u8 \\\n    ghcr.io/aperim/nvidia-cuda-ffmpeg:latest mosaic\n```\n\nWould generate this example output\n\n```text\n🖥️ mosaic command\ndocker run -it --rm --gpus=all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all \\\n        -e INPUT0=\"/etc/mosaic/1920x1080-black.png\" \\\n        -e INPUT1=\"https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8\" \\\n        -e INPUT2=\"https://d3rlna7iyyu8wu.cloudfront.net/skip_armstrong/skip_armstrong_multichannel_subs.m3u8\" \\\n        -e INPUT3=\"http://amssamples.streaming.mediaservices.windows.net/634cd01c-6822-4630-8444-8dd6279f94c6/CaminandesLlamaDrama4K.ism/manifest(format=m3u8-aapl)\" \\\n        -e INPUT4=\"https://devimages.apple.com.edgekey.net/iphone/samples/bipbop/bipbopall.m3u8\" \\\n        -e CONTAINER=\"mpegts\" \\\n        -e OUTPUT=\"udp://224.0.51.1:1234?pkt_size=188\" \\\n        -e BITRATE=\"8M\" \\\n        -e ENCODER=\"hevc\" \\\n        -e WIDTH=\"1920\" \\\n        -e HEIGHT=\"1080\" \\\n        -e FFMPEG_THREAD_QUEUE_SIZE=\"512\" \\\n        -e FFMPEG_CUDA_FORMAT=\"nv12\" \\\n        ghcr.io/aperim/nvidia-cuda-ffmpeg:latest mosaic\n\n⌨️ ffmpeg command\ndocker run -it --rm --gpus=all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all ghcr.io/aperim/nvidia-cuda-ffmpeg:latest \\\n        -nostats -y -hide_banner -loglevel warning -err_detect ignore_err \\\n        -thread_queue_size 512 -hwaccel cuda -hwaccel_output_format nv12 -i /etc/mosaic/1920x1080-black.png \\\n        -reconnect_on_network_error 1 -reconnect_on_http_error 1 -reconnect_streamed 1 -reconnect_delay_max 2000-thread_queue_size 512 -hwaccel cuda -hwaccel_output_format nv12 -i https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8 \\\n        -reconnect_on_network_error 1 -reconnect_on_http_error 1 -reconnect_streamed 1 -reconnect_delay_max 2000-thread_queue_size 512 -hwaccel cuda -hwaccel_output_format nv12 -i https://d3rlna7iyyu8wu.cloudfront.net/skip_armstrong/skip_armstrong_multichannel_subs.m3u8 \\\n        -reconnect_on_network_error 1 -reconnect_on_http_error 1 -reconnect_streamed 1 -reconnect_delay_max 2000-thread_queue_size 512 -hwaccel cuda -hwaccel_output_format nv12 -i http://amssamples.streaming.mediaservices.windows.net/634cd01c-6822-4630-8444-8dd6279f94c6/CaminandesLlamaDrama4K.ism/manifest(format=m3u8-aapl) \\\n        -reconnect_on_network_error 1 -reconnect_on_http_error 1 -reconnect_streamed 1 -reconnect_delay_max 2000-thread_queue_size 512 -hwaccel cuda -hwaccel_output_format nv12 -i https://devimages.apple.com.edgekey.net/iphone/samples/bipbop/bipbopall.m3u8 \\\n        -filter_complex \" \\\n         \\\n        [0:v]format=nv12,hwupload_cuda,scale_cuda=-2:w=1920:h=1080:format=nv12[base]; \\\n        [1:v]format=nv12,hwupload_cuda,scale_cuda=-2:w=960:h=540:format=nv12,fps=24,setpts=PTS-STARTPTS[panel1]; \\\n        [2:v]format=nv12,hwupload_cuda,scale_cuda=-2:w=960:h=540:format=nv12,fps=24,setpts=PTS-STARTPTS[panel2]; \\\n        [3:v]format=nv12,hwupload_cuda,scale_cuda=-2:w=960:h=540:format=nv12,fps=24,setpts=PTS-STARTPTS[panel3]; \\\n        [4:v]format=nv12,hwupload_cuda,scale_cuda=-2:w=960:h=540:format=nv12,fps=24,setpts=PTS-STARTPTS[panel4]; \\\n        [base][panel1]overlay_cuda=shortest=0:x=0:y=0[layer1]; \\\n        [layer1][panel2]overlay_cuda=shortest=0:x=960:y=0[layer2]; \\\n        [layer2][panel3]overlay_cuda=shortest=0:x=0:y=540[layer3]; \\\n        [layer3][panel4]overlay_cuda=shortest=0:x=960:y=540[final] \\\n         \\\n        \" \\\n        -map \"[final]\" -c:v hevc_nvenc -preset fast -tune ull -zerolatency 1 -b:v 8M \\\n        -map 1:a:1\\? -map 2:a:2\\? -map 3:a:3\\? -map 4:a:4\\? \\\n        -f mpegts \"udp://224.0.51.1:1234?pkt_size=188\"\n```\n\n### Camera\n\nUsing command, pass a source and destination and the script will generate the ffmpeg command to transcode and send your camera feed.\n\n```bash\ndocker run -it --rm --gpus=all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all ghcr.io/aperim/nvidia-cuda-ffmpeg:latest camera \\\n\trtsp://user:pass@192.0.2.1/unicast/c1/s0/live rtsp://host.docker.internal:8554/camera1 16M h264 24\n```\n\n```text\nCamera Transcode\n        Usage - pass the camera url and the destination\n                camera \u003ccamera_url\u003e \u003cdestination_url\u003e [bitrate] [encoder] [framerate]\n                        camera_url The url of your camera - with url encoded usernmame/password if needed\n                        destination_url The destination URL\n                        bitrate (optional) The output bitrate [default 8M]\n                        encoder (optional) Either h264 or hevc [default hevc]\n                        framerate (optional) The frame rate [no default]\n        Example\n                camera rtsp://admin@passw0rd:192.0.2.1/main/0 rtsp://streaming.server.example/camera1 16M h264 24\n        Note\n                The output url must be RTSP. It will be using TCP\n```\n\n### Camera Reboot Box\n\nReboots the generic box style camera firmware being used by a lot of aliexpress type shippers.\n\n```bash\ndocker run -it --rm --gpus=all -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all ghcr.io/aperim/nvidia-cuda-ffmpeg:latest camera-reboot-box \\\n\t--host camerahost.example.com \\\n  --username CAMERAUSERNAME \\\n  --password CAMERAPASSWORD \\\n  --timeout TIMEOUT_IN_SECONDS\n```\n\n```text\nBox Style Camera Reboot\n      Usage - pass the host, username and password\n            camera-box-reboot --host \u003chost\u003e --username \u003cusername\u003e --password \u003cpassword\u003e [--timeout \u003ctimeout\u003e]\n                  host the hostname or ip of the camera\n                  username the admin username for the camera\n                  password the admin password for the camera\n                  timeout seconds to wait for camera to reboot\n      Example\n            camera-box-reboot --host camera1.example.com --username admin --password s5cr3t\n            camera-box-reboot --host 198.51.100.100 --username camerauser --password d4ng3R! --timeout 30\n      Note\n            This will reboot the camera, that's it.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faperim%2Fdocker-nvidia-cuda-ffmpeg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faperim%2Fdocker-nvidia-cuda-ffmpeg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faperim%2Fdocker-nvidia-cuda-ffmpeg/lists"}