aoirint / ffmpeg-docker

最新のFFmpegを使うためのDockerイメージ
https://hub.docker.com/r/aoirint/ffmpeg
The Unlicense
0 stars 0 forks source link

NVIDIA GPUのハードウェアコーデックが利用できない #28

Closed aoirint closed 1 month ago

aoirint commented 11 months ago

以下で導入したと思っていたけれど、導入できていなさそう。

明示的にビルドオプションを指定する必要がありそう。

aoirint commented 10 months ago

Not working yet.

Error log ```shell $ sudo docker run --rm --gpus all -v ".:/a" -w /a ffmpeg:nvidia -i 2023-11-10_21-01-20_game4.mkv -c:v h264 _nvenc -c:a copy -map 0 -map_metadata 0 2023-11-10_21-01-20_game4_reenc.mkv ffmpeg version n6.0.1 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04) configuration: --prefix=/usr/local --pkg-config-flags=--static --extra-libs='-lpthread -lm' --ld=g++ --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libsvtav1 --enable-libdav1d --enable-libvmaf --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100 Input #0, matroska,webm, from '2023-11-10_21-01-20_game4.mkv': Metadata: ENCODER : Lavf58.76.100 Duration: 00:28:01.04, start: 0.000000, bitrate: 5719 kb/s Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 1k tbn (default) Metadata: DURATION : 00:28:01.037000000 Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default) Metadata: title : Mixed Audio DURATION : 00:28:01.023000000 Stream #0:2: Audio: aac (LC), 48000 Hz, stereo, fltp Metadata: title : App Audio DURATION : 00:28:01.023000000 Stream #0:3: Audio: aac (LC), 48000 Hz, stereo, fltp Metadata: title : Mic DURATION : 00:28:01.023000000 Stream #0:4: Audio: aac (LC), 48000 Hz, stereo, fltp Metadata: title : Browser DURATION : 00:28:01.023000000 Stream #0:5: Audio: aac (LC), 48000 Hz, stereo, fltp Metadata: title : Discord DURATION : 00:28:01.023000000 Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc)) Stream #0:1 -> #0:1 (copy) Stream #0:2 -> #0:2 (copy) Stream #0:3 -> #0:3 (copy) Stream #0:4 -> #0:4 (copy) Stream #0:5 -> #0:5 (copy) Press [q] to stop, [?] for help [h264_nvenc @ 0x55d6ef00c000] Cannot load libnvidia-encode.so.1 [h264_nvenc @ 0x55d6ef00c000] The minimum required Nvidia driver for nvenc is (unknown) or newer [vost#0:0/h264_nvenc @ 0x55d6eeff3500] Error initializing output stream: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed! ```
aoirint commented 10 months ago

コンテナ実行時のオプションで解決しそう。

$ sudo docker pull nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu22.04
11.8.0-devel-ubuntu22.04: Pulling from nvidia/cuda
Digest: sha256:94fd755736cb58979173d491504f0b573247b1745250249415b07fefc738e41f
Status: Image is up to date for nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu22.04
nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu22.04

$ sudo docker run --rm --gpus all -it nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu22.04 bash
# find / -name 'libnvidia-encode*'
(empty output)

$ sudo docker run --rm --gpus all,capabilities=video -it nvcr.io/nvidia/cuda:11.8.0-devel-ubuntu22.04 bash
# find / -name 'libnvidia-encode*'
/usr/lib/x86_64-linux-gnu/libnvidia-encode.so.545.23.06
/usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1
aoirint commented 10 months ago
$ sudo docker pull nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
12.1.1-cudnn8-devel-ubuntu22.04: Pulling from nvidia/cuda
Digest: sha256:21196d81f56b48dbee70494d5f10322e1a77cc47ffe202a3bf68eab81533c20f
Status: Image is up to date for nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04

$ sudo docker run --rm --gpus all -it nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 bash
# find / -name 'libnvidia-encode*'
(empty output)

$ sudo docker run --rm --gpus all,capabilities=video -it nvcr.io/nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 bash
# find / -name 'libnvidia-encode*'
/usr/lib/x86_64-linux-gnu/libnvidia-encode.so.545.23.06
/usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1
aoirint commented 10 months ago

FFmpegがCUDAの機能を使う場合があるらしいから、capabilities=gpu,videoのほうがよさそう

aoirint commented 10 months ago
$ sudo docker run --rm --gpus "all,capabilities=xxx" -v ".:/a" -w /a ffmpeg:nvidia -i 2023-11-10_21-01-20_game4.mkv -c:v h264_nvenc -c:a copy -map 0 -map_metadata 0 2023-11-10_21-01-20_game4_reenc.mkv
docker: Error response from daemon: could not select device driver "" with capabilities: [[xxx gpu]].

$ sudo docker run --rm --gpus "all,capabilities=xxx,video" -v ".:/a" -w /a ffmpeg:nvidia -i 2023-11-10_21-01-20_game4.mkv -c:v h264_nvenc -c:a copy -map 0 -map_metadata 0 2023-11-10_21-01-20_game4_reenc.mkv
invalid argument "all,capabilities=xxx,video" for "--gpus" flag: count must be an integer: strconv.Atoi: parsing "video": invalid syntax
See 'docker run --help'.
aoirint commented 1 month ago

closed by #39