This repository contains a Dockerfile to build a Docker image for FFmpeg with NVIDIA NVENC support. The image is based on nvidia/cuda:11.8.0-base-ubuntu20.04
and includes support for hardware acceleration using NVIDIA GPUs.
- CUDA 11.8
- FFmpeg 5.1
- NVIDIA NVENC hardware acceleration
- A machine with an NVIDIA GPU
- NVIDIA drivers installed
- Docker installed
- Clone the repository:
git clone https://github.com/<your-username>/ffmpeg-nvenc-docker.git cd ffmpeg-nvenc-docker
- Build the Docker image:
docker build -t ffmpeg-nvenc .
docker run --rm --gpus all ffmpeg-nvenc:latest ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc -preset slow -b:v 5M output.mp4
docker run --rm --gpus all ffmpeg-nvenc:latest ffmpeg -encoders | grep nvenc
On NixOS, the --gpus all option may not work as expected. Instead, you can use the --device nvidia.com/gpu=all option to enable GPU access for the container. Additionally, ensure your NixOS system is configured with the hardware.nvidia-container-toolkit module to support NVIDIA GPU containers.
Here’s an example of the adjusted command:
docker run --rm --device nvidia.com/gpu=all ffmpeg-nvenc:latest ffmpeg -hwaccel cuda -i input.mp4 -c:v h264_nvenc -preset slow -b:v 5M output.mp4