docker-ffmpeg icon indicating copy to clipboard operation
docker-ffmpeg copied to clipboard

[FEAT] Add Nvidia support to aarch64 image

Open mwilsonav opened this issue 2 years ago • 10 comments

Is this a new feature request?

  • [X] I have searched the existing issues

Wanted change

I would like to support nvenc and nvdec for aarch64

Reason for change

There is a good population of Nvidia Tegra based ARM devices out there, see the Jetson device family for examples. Many, such as the AGX Orin have nvenc chips and all Jetson devices support CUDA.

Proposed code change

Add support to the Dockerfile.aarch64 file following instructions here: https://docs.nvidia.com/video-technologies/video-codec-sdk/12.0/ffmpeg-with-nvidia-gpu/index.html.

mwilsonav avatar Oct 31 '23 19:10 mwilsonav

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

github-actions[bot] avatar Oct 31 '23 19:10 github-actions[bot]

@mwilsonav can you give this image a try? I have no way of testing. ghcr.io/linuxserver/lsiodev-ffmpeg:arm64v8-6.1-cli-pkg-d0edb0ca-dev-5ec39d8e395cf43fae625f8c718f8214f58bde63

FFmpeg in there is compiled with support for cuvid, nvdec and nvenc. You need to make sure the container is using nvidia-runtime or has the gpu/cuda support injected by docker.

aptalca avatar Nov 13 '23 21:11 aptalca

@aptalca Thanks for putting this together. I got a few errors on my end when I tried it

My command line: docker run --rm -it --runtime=nvidia -v $(pwd):/config ghcr.io/linuxserver/lsiodev-ffmpeg:6.1-cli-pkg-d0edb0ca-dev-5ec39d8e395cf43fae625f8c718f8214f58bde63 -hwaccel nvdec -i rtsp://192.168.2.11:554/stream0 -c:v hevc_nvenc -b:v 4M -vf scale=1280:720 -c:a copy output.mkv

Output of the command: ffmpeg version 6.1 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04) configuration: --disable-debug --disable-doc --disable-ffplay --enable-cuvid --enable-ffprobe --enable-gpl --enable-libaom --enable-libass --enable-libfdk_aac --enable-libfreetype --enable-libkvazaar --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-nonfree --enable-nvdec --enable-nvenc --enable-openssl --enable-stripping --enable-version3 libavutil 58. 29.100 / 58. 29.100 libavcodec 60. 31.102 / 60. 31.102 libavformat 60. 16.100 / 60. 16.100 libavdevice 60. 3.100 / 60. 3.100 libavfilter 9. 12.100 / 9. 12.100 libswscale 7. 5.100 / 7. 5.100 libswresample 4. 12.100 / 4. 12.100 libpostproc 57. 3.100 / 57. 3.100 Input #0, rtsp, from 'rtsp://admin:[email protected]:554/stream0': Metadata: title : RTSP/RTP stream from icamra ipc Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: h264 (High), yuv420p(progressive), 2560x1440, 10 fps, 10 tbr, 90k tbn Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s [AVHWDeviceContext @ 0xaaaaeb357cd0] Cannot load libcuda.so.1 [AVHWDeviceContext @ 0xaaaaeb357cd0] Could not dynamically load CUDA Device creation failed: -1. No device available for decoder: device type cuda needed for codec h264. [vist#0:0/h264 @ 0xaaaaeb186550] Hardware device setup failed for decoder: Operation not permitted [vost#0:0/hevc_nvenc @ 0xaaaaeb1f9700] Error initializing a simple filtergraph Error opening output file output.mkv. Error opening output files: Operation not permitted

The permissions errors on the output files may be bogus, I didn't really dig into those, however the cuda errors seem relevant.

mwilsonav avatar Nov 15 '23 00:11 mwilsonav

@mwilsonav ah, I forgot to set the nvidia vars in the dockerfile. Try setting these in the docker run: https://github.com/linuxserver/docker-ffmpeg/blob/master/Dockerfile#L709-L710

aptalca avatar Nov 15 '23 00:11 aptalca

A few new errors now: [h264 @ 0xaaaaee5dc8a0] Cannot load libnvcuvid.so.1 [h264 @ 0xaaaaee5dc8a0] Failed loading nvcuvid. [h264 @ 0xaaaaee5dc8a0] Failed setup for format cuda: hwaccel initialisation returned error. [hevc_nvenc @ 0xaaaaee476750] Cannot load libnvidia-encode.so.1

mwilsonav avatar Nov 15 '23 01:11 mwilsonav

That lib should be injected by nvidia-runtime. Make sure it's installed and enabled properly on the host. You can try the other images nvidia provides for testing.

aptalca avatar Nov 22 '23 19:11 aptalca

New image with the Nvidia env vars set. It just needs nvidia runtime or container toolkit enabled for the container: ghcr.io/linuxserver/lsiodev-ffmpeg:arm64v8-6.1-cli-pkg-d0edb0ca-dev-8432dfe76d86ed2322389f36d1835dc6a40b8f87

aptalca avatar Dec 06 '23 16:12 aptalca

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

LinuxServer-CI avatar Jan 06 '24 01:01 LinuxServer-CI

@mwilsonav this is waiting on your testing

thelamer avatar Feb 14 '24 19:02 thelamer

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

LinuxServer-CI avatar Mar 17 '24 01:03 LinuxServer-CI

This issue is locked due to inactivity

github-actions[bot] avatar Jun 15 '24 01:06 github-actions[bot]