有没有办法在不使用 cuda 的情况下将 nvenc 用于 ffmpeg?

有没有办法在不使用 cuda 的情况下将 nvenc 用于 ffmpeg?

我遇到了一个问题,ffmpeg 挂起了而不是编码。

我正在尝试使用 nvenc nvidia hw accel 编码器。

下面的日志表明它正在(尝试)使用 cuda。

不过,我怀疑它挂起的原因是因为其正在尝试使用 cuda。

有没有办法使用 nvenc 编码器无需使用 cuda

因此,作为解决问题过程的一部分,我尝试使用 nvenc 但不使用 cuda - 这可能吗?

:ubuntu:/dev/shm> ffmpeg -y -f h264 -i foo0.h264  -c:v h264_nvenc -pix_fmt yuv420p foo0x.mp4  -loglevel debug
ffmpeg version N-94712-gcc78783 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1)
  configuration: --prefix=/home/ubuntu/ffmpeg_compile/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/ubuntu/ffmpeg_compile/ffmpeg_build/include --extra-ldflags=-L/home/ubuntu/ffmpeg_compile/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/ubuntu/ffmpeg_compile/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 34.100 / 56. 34.100
  libavcodec     58. 56.101 / 58. 56.101
  libavformat    58. 32.104 / 58. 32.104
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 58.102 /  7. 58.102
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'h264'.
Reading option '-i' ... matched as input url with argument 'foo0.h264'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_nvenc'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option 'foo0x.mp4' ... matched as output url.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url foo0.h264.
Applying option f (force format) with argument h264.
Successfully parsed a group of options.
Opening an input file: foo0.h264.
[h264 @ 0x55b6755a19c0] Opening 'foo0.h264' for reading
[file @ 0x55b6755a2500] Setting default whitelist 'file,crypto'
[h264 @ 0x55b6755a19c0] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[AVBSFContext @ 0x55b6755ca0c0] nal_unit_type: 7(SPS), nal_ref_idc: 3
[AVBSFContext @ 0x55b6755ca0c0] nal_unit_type: 8(PPS), nal_ref_idc: 3
[AVBSFContext @ 0x55b6755ca0c0] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x55b6755a3840] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x55b6755a3840] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x55b6755a3840] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x55b6755a3840] Format yuv420p chosen by get_format().
[h264 @ 0x55b6755a3840] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 0x55b6755a3840] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
    Last message repeated 5 times
[h264 @ 0x55b6755a19c0] Probe buffer size limit of 5000000 bytes reached
[h264 @ 0x55b6755a19c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
[h264 @ 0x55b6755a19c0] After avformat_find_stream_info() pos: 5142528 bytes read:5144576 seeks:0 frames:7
Input #0, h264, from 'foo0.h264':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 7, 1/1200000: Video: h264 (High 4:4:4 Predictive), 1 reference frame, yuv420p(progressive, left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 0/1, 25 fps, 25 tbr, 1200k tbn, 50 tbc
Successfully opened the file.
Parsing a group of options: output url foo0x.mp4.
Applying option c:v (codec name) with argument h264_nvenc.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Successfully parsed a group of options.
Opening an output file: foo0x.mp4.
[file @ 0x55b6755a4ec0] Setting default whitelist 'file,crypto'
Successfully opened the file.
detected 16 logical cores
[h264 @ 0x55b6755a7280] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x55b6755a7280] nal_unit_type: 8(PPS), nal_ref_idc: 3
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
[h264 @ 0x55b6755a7280] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x55b6755a7280] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x55b6755a7280] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x55b6755a7280] Format yuv420p chosen by get_format().
[h264 @ 0x55b6755a7280] Reinit context to 1920x1088, pix_fmt: yuv420p
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675db2140] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675acb740] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675c0b540] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675c28040] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675c448c0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675c61080] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675c7d840] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675c9a000] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675882700] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b67589ef80] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b6758bb740] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b6758d7f00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b6758f49c0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 0x55b675911180] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x55b67592d940] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[graph 0 input from stream 0:0 @ 0x55b67576c400] Setting 'video_size' to value '1920x1080'
[graph 0 input from stream 0:0 @ 0x55b67576c400] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x55b67576c400] Setting 'time_base' to value '1/1200000'
[graph 0 input from stream 0:0 @ 0x55b67576c400] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 0x55b67576c400] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x55b67576c400] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 0:0 @ 0x55b67576c400] w:1920 h:1080 pixfmt:yuv420p tb:1/1200000 fr:25/1 sar:1/1 sws_param:flags=2
[format @ 0x55b676ffc280] Setting 'pix_fmts' to value 'yuv420p'
[AVFilterGraph @ 0x55b675a83d00] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
[h264_nvenc @ 0x55b6755a8700] Loaded lib: libcuda.so.1
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuInit
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuDeviceGetCount
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuDeviceGet
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuDeviceGetAttribute
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuDeviceGetName
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuDeviceComputeCapability
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuCtxCreate_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuCtxSetLimit
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuCtxPushCurrent_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuCtxPopCurrent_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuCtxDestroy_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuMemAlloc_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuMemAllocPitch_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuMemsetD8Async
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuMemFree_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuMemcpy2D_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuMemcpy2DAsync_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuGetErrorName
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuGetErrorString
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuStreamCreate
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuStreamQuery
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuStreamSynchronize
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuStreamDestroy_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuStreamAddCallback
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuEventCreate
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuEventDestroy_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuEventSynchronize
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuEventQuery
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuEventRecord
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuLaunchKernel
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuModuleLoadData
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuModuleUnload
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuModuleGetFunction
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuTexObjectCreate
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuTexObjectDestroy
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuGLGetDevices_v2
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuGraphicsGLRegisterImage
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuGraphicsUnregisterResource
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuGraphicsMapResources
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuGraphicsUnmapResources
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuGraphicsSubResourceGetMappedArray
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuDeviceGetUuid
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuImportExternalMemory
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuDestroyExternalMemory
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuExternalMemoryGetMappedBuffer
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuExternalMemoryGetMappedMipmappedArray
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuMipmappedArrayGetLevel
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuMipmappedArrayDestroy
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuImportExternalSemaphore
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuDestroyExternalSemaphore
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuSignalExternalSemaphoresAsync
[h264_nvenc @ 0x55b6755a8700] Loaded sym: cuWaitExternalSemaphoresAsync
[h264_nvenc @ 0x55b6755a8700] Loaded lib: libnvidia-encode.so.1
[h264_nvenc @ 0x55b6755a8700] Loaded sym: NvEncodeAPICreateInstance
[h264_nvenc @ 0x55b6755a8700] Loaded sym: NvEncodeAPIGetMaxSupportedVersion
[h264_nvenc @ 0x55b6755a8700] Loaded Nvenc version 9.0
[h264_nvenc @ 0x55b6755a8700] Nvenc initialized successfully
[h264_nvenc @ 0x55b6755a8700] 1 CUDA capable devices found
[h264_nvenc @ 0x55b6755a8700] [ GPU #0 - < Tesla M60 > has Compute SM 5.2 ]
[h264_nvenc @ 0x55b6755a8700] supports NVENC
:ubuntu:/dev/shm>

相关内容