ffmpeg GPU 使用 cuvid 与 hwdownload 永远不会完成,最近才出现

ffmpeg GPU 使用 cuvid 与 hwdownload 永远不会完成,最近才出现

ffmpeg:

ffmpeg version N-97331-g10a68cc Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --pkg-config-flags=--static --prefix=/usr/local/ffmpeg --bindir=/usr/local/ffmpeg/bin --extra-cflags='-I /usr/local/ffmpeg/include -I /usr/local/cuda/include/' --extra-ldflags='-L /usr/local/ffmpeg/lib -L /usr/local/cuda/lib64/' --extra-libs=-lpthread --enable-cuda --enable-cuda-nvcc --enable-cuvid --enable-libnpp --enable-gpl --enable-libass --enable-libfdk-aac --enable-vaapi --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libaom --enable-nvenc

nvidia-msi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.82       Driver Version: 440.82       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:02:00.0 Off |                  N/A |
|  0%   51C    P8    13W / 200W |     18MiB /  8119MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     23224      C   ffmpeg                                         8MiB |
+-----------------------------------------------------------------------------+

如果我使用这个命令:

ffmpeg -re -threads 0 -loglevel debug -hwaccel cuvid -hwaccel_output_format cuda -i 1.mp4 -c:v h264_nvenc -c:a aac -ac 2 -b:a 128k -strict -2 -filter_complex "[0:v]scale_npp=1280:-2" ouzz2t.mp4

它会非常快。

但如果我使用这个命令:

ffmpeg -re -threads 0 -loglevel debug -vsync 0 -hwaccel cuvid -hwaccel_output_format cuda -hwaccel_device intel -i 1.mp4 -c:v h264_nvenc -c:a aac -ac 2 -b:a 128k -strict -2 -filter_complex "[0:v]scale_npp=1280:-2:format=yuv420p[tmp],[tmp]hwdownload,format=yuv420" ouzz2t.mp4

它永远不会完成,一个 40MB 的 mp4 将转码 44 分钟但不会完成。

如你所见

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     23224      C   ffmpeg                                         8MiB |
+-----------------------------------------------------------------------------+

它将仅使用 GPU 内存 8mib 并且 top 将显示:

顶部截图

调试日志:

[AVHWDeviceContext @ 0x561cfaef92c0] Loaded lib: libcuda.so.1
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuInit
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDeviceGetCount
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDeviceGet
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDeviceGetAttribute
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDeviceGetName
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDeviceComputeCapability
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuCtxCreate_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuCtxSetLimit
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuCtxPushCurrent_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuCtxPopCurrent_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuCtxDestroy_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuMemAlloc_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuMemAllocPitch_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuMemsetD8Async
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuMemFree_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuMemcpy2D_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuMemcpy2DAsync_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuGetErrorName
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuGetErrorString
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuCtxGetDevice
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDevicePrimaryCtxRetain
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDevicePrimaryCtxRelease
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDevicePrimaryCtxSetFlags
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDevicePrimaryCtxGetState
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDevicePrimaryCtxReset
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuStreamCreate
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuStreamQuery
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuStreamSynchronize
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuStreamDestroy_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuStreamAddCallback
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuEventCreate
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuEventDestroy_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuEventSynchronize
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuEventQuery
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuEventRecord
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuLaunchKernel
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuModuleLoadData
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuModuleUnload
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuModuleGetFunction
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuTexObjectCreate
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuTexObjectDestroy
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuGLGetDevices_v2
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuGraphicsGLRegisterImage
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuGraphicsUnregisterResource
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuGraphicsMapResources
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuGraphicsUnmapResources
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuGraphicsSubResourceGetMappedArray
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDeviceGetUuid
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuImportExternalMemory
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDestroyExternalMemory
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuExternalMemoryGetMappedBuffer
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuExternalMemoryGetMappedMipmappedArray
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuMipmappedArrayGetLevel
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuMipmappedArrayDestroy
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuImportExternalSemaphore
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuDestroyExternalSemaphore
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuSignalExternalSemaphoresAsync
[AVHWDeviceContext @ 0x561cfaef92c0] Loaded sym: cuWaitExternalSemaphoresAsync

在 Loaded sym: cuWaitExternalSemaphoresAsync 处停止,ffmpeg 将始终占用 100% CPU 并且永远不会完成。

只是最近才出现,上周运行良好,但今天运行得更糟了。

有人知道我发生了什么事吗?

相关内容