ffmpeg - 如何使用 FFMPEG 多 GPU 进程

标签 ffmpeg gpu nvidia multi-gpu

我有一个问题,找不到任何合适的答案。
它关于使用多 GPU 进程。
我有 3 个显卡,你可以看到它:
[![在此处输入图像描述][1]][1]
如果图片未加载,请使用此图片链接:/image/msR83.jpg enter link description here

我的问题是:当我使用 cuda 运行多个 ffmpeg 命令时,所有进程都分配给了第一个 GPU。
如下图:
[![在此处输入图像描述][2]][2]
如果图片未加载,请使用此图片链接:/image/PfYfz.jpg
你看?分配给第一个 GPU 的所有 6 个进程。
我真的很困惑我该如何解决它。

我的 FFMPEG 代码是:

ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i my-video.mp4 \
  -vf scale_npp=w=426:h=240 -c:v h264_nvenc -profile:v main -b:v 400k -sc_threshold 0 -g 25 \
  -c:a aac -b:a 64k -ar 48000 \
  -f hls -hls_time 6 -hls_playlist_type vod \
  -hls_allow_cache 1 -hls_key_info_file encription.keyinfo \
  -hls_segment_filename f-0-seg-%d.ts f-0.m3u8
我同时为 6 个不同的视频运行顶级 FFMPEG 代码。
请帮助找到答案。通过分享您的知识或一些可以帮助我的链接。
非常感谢。

最佳答案

据我所知,这个过程似乎相当简单:
https://developer.nvidia.com/blog/nvidia-ffmpeg-transcoding-guide/

Encoding and decoding work must be explicitly assigned to a GPU when using multiple GPUs in one system. GPUs are identified by their index number; by default all work is performed on the GPU with index 0. Use the following command to obtain a list of all NVIDIA GPUs in the system and their corresponding ID numbers:

ffmpeg -vsync 0 -i input.mp4 -c:v h264_nvenc -gpu list -f null –

Once you know the index, the -hwaccel_device index flag can be used to set the active GPU for decoding and encoding. In the example below the work will be executed on the gpu with index 1.

ffmpeg -vsync 0 -hwaccel cuvid -hwaccel_device 1 -c:v h264_cuvid -i input.mp4 -c:a copy -c:v h264_nvenc -b:v 5M output.mp4

关于ffmpeg - 如何使用 FFMPEG 多 GPU 进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65983094/

相关文章:

C++如何检测显卡型号

python - 如何让这段RL代码获得GPU支持?

python - 如何强制 scipy.optimize.fmin_l_bfgs_b 使用 'dtype=float32'

c# - 从 MP4 视频创建缩略图在共享主机上崩溃,但在本地工作正常

android - react native ffmpeg : Native module cannot be null (ios) and null is not an object (evaluating 'RNFFmpegModule.enableLogEvents' ) (android)

video - 使用ffmpeg向视频添加背景音乐?

unix - 将多个ffmpeg命令合并为一行,使整个过程更快

python - 我可以在 python 程序上使用 cuda-memcheck

winsock - 如何调查仅在配备 NVIDIA Quadro 的机器上经常发生的客户端 WSAECONNABORTED?

parallel-processing - NVidia 是否支持 OpenCL SPIR?