FFMPEG NVENC HEVC至H264

时间:2019-11-01 14:34:00

标签: ffmpeg nvenc

我尝试将HEVC 4k广播转码为1080p H264。从HEVC 4K到HEVC 1080p可以工作,但是当我尝试从hevc到h264时,出现“找不到支持NVENC的设备”

现在我想知道是否不可能将HEVC完全转码为H264?

使用的代码:

ffmpeg -timeout 10000000 -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 2 -hwaccel_device 0 -hwaccel cuvid -vcodec hevc_cuvid -resize 1920x1080 -i 'http://inputstream' -max_muxing_queue_size 1024 -map 0:0 -map 0:2 -acodec libfdk_aac -b:a 96k -c:v h264_nvenc -gpu 0 -preset llhq -profile high -rc:v vbr -qmin:v 26 -qmax:v 32 -b:v 4M -maxrate 4M -bufsize 8M -threads 0 -r 25 -g 100 -f mpegts 'udp://127.0.0.1:6472' 

当我运行代码时:

[h264_nvenc @ 0x3bf42c0]提供的设备不支持必需的NVENC功能 初始化输出流0:0时出错-打开输出流#0:0的编码器时出错-可能是不正确的参数,例如bit_rate,rate,width或height 转换失败!

是否无法将HEVC转换回H264?

日志:

root@sambir-T5600:~# ffmpeg -timeout 10000000 -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 2 -hwaccel_device 0 -hwaccel cuvid -vcodec hevc_cuvid -resize 1920x1080 -i 'http://192.168.1.12:8001/1:0:19:3FAC:7851:ABC:1A40000:0:0:0:' -max_muxing_queue_size 1024 -map 0:0 -map 0:2 -acodec libfdk_aac -b:a 96k -c:v h264_nvenc -gpu 0 -preset llhq -vprofile high -rc:v vbr -qmin:v 26 -qmax:v 35 -b:v 4M -maxrate 4M -bufsize 8M -threads 0 -r 25 -g 100 -f mpegts 'udp://127.0.0.1:6472'
ffmpeg version N-95090-g646799b Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.4)
  configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --enable-cuda-nvcc --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/cuda/include/ --extra-ldflags=-L/usr/local/cuda/lib64/ --enable-gpl --enable-libass --enable-libfdk-aac --enable-libx264 --enable-libx265 --enable-pic --extra-libs='-lpthread -lm -lz -ldl' --enable-nvenc --enable-nonfree
  libavutil      56. 35.100 / 56. 35.100
  libavcodec     58. 59.100 / 58. 59.100
  libavformat    58. 33.100 / 58. 33.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 59.100 /  7. 59.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
[hevc @ 0x44d8000] PPS id out of range: 0
    Last message repeated 1 times
[hevc @ 0x44d8000] Error parsing NAL unit #2.
Input #0, mpegts, from 'http://192.168.1.12:8001/1:0:19:3FAC:7851:ABC:1A40000:0:0:0:':
  Duration: N/A, start: 21829.677256, bitrate: N/A
  Program 16300
    Stream #0:0[0x12f7]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv), 3840x2160 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x135b]: Audio: eac3 ([6][0][0][0] / 0x0006), 48000 Hz, 5.1(side), fltp, 256 kb/s
    Stream #0:2[0x13bf]: Audio: aac (HE-AAC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 80 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (hevc_cuvid) -> h264 (h264_nvenc))
  Stream #0:2 -> #0:1 (aac (native) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
[h264_nvenc @ 0x44df300] Provided device doesn't support required NVENC features
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

2 个答案:

答案 0 :(得分:0)

没有用于测试的文件,但我认为您会收到此错误,因为NVENC H264不支持yuv420p10le。尝试将-pix_fmt nv12添加到命令中,以将其转换为它支持的格式。

在4.2.1版中, ffmpeg -h encoder=nvenc_h264 输出有关编码器的信息,包括:

Supported pixel formats: yuv420p nv12 p010le yuv444p p016le yuv444p16le bgr0 rgb0 cuda d3d11

答案 1 :(得分:0)

似乎您的视频卡不支持这种编码,例如,当我尝试在nvidia M200卡上将10bit的HEVC 4k视频转换为10k时,我却遇到了同样的错误,但是当我将卡式卡转换为pascaul nvidia P2000时,它就可以工作了