[FFmpeg-user] Issue with hwaccel cuvid

Andy Sheimo asheimo at gmail.com
Wed Apr 8 19:03:54 EEST 2020


This still produces the same error;

ffmpeg -threads 1 -loglevel verbose -hwaccel cuvid
-hwaccel_output_format cuda -c:v mpeg2_cuvid -extra_hw_frames 3 -i
"l:\welter_originals\gamera the brave\Latatude Zero-trailer.mkv" -c:a copy
-c:v h264_nvenc test.mkv

But this works to complete the job;

ffmpeg -threads 1 -loglevel verbose -hwaccel cuda
-hwaccel_output_format cuda -extra_hw_frames 3 -i
"l:\welter_originals\gamera the brave\Latatude Zero-trailer.mkv" -c:a copy
-c:v h264_nvenc test.mkv

By not specifying  -c:v mpeg2_cuvid do we know what decoder is being used?
Is the process still completely in hardware? Do you think this is a
limitation of the cuvid decoder?

Thanks for your help. -Andy

On Wed, Apr 8, 2020 at 11:36 AM Dennis Mungai <dmngaie at gmail.com> wrote:

> On Wed, 8 Apr 2020 at 17:57, Andy Sheimo <asheimo at gmail.com> wrote:
>
> > I keep getting an error on some files and it appears to be due to a
> > scaler being inserted but I don't know how to fix it. Any help would be
> > appreciated. logging below:
> >
> > K:\Video\GAMERA THE BRAVE>ffmpeg -loglevel verbose -hwaccel cuvid
> > -hwaccel_output_format yuv420p -c:v mpeg2_cuvid -i
> > "l:\welter_originals\gamera the brave\Latatude Zero-trailer.mkv" -c:a
> copy
> > -c:v h264_nvenc test.mkv
> > ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
> >   built with gcc 9.2.1 (GCC) 20200122
> >   configuration: --enable-gpl --enable-version3 --enable-sdl2
> > --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass
> > --enable-libdav1d --enable-libbluray --enable-libfreetype
> > --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
> > --enable-libopenjpeg --enable-libopus --enable-libshine
> --enable-libsnappy
> > --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx
> > --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
> > --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib
> --enable-gmp
> > --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc
> > --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom
> > --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid
> > --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2
> > --enable-avisynth --enable-libopenmpt
> >   libavutil      56. 31.100 / 56. 31.100
> >   libavcodec     58. 54.100 / 58. 54.100
> >   libavformat    58. 29.100 / 58. 29.100
> >   libavdevice    58.  8.100 / 58.  8.100
> >   libavfilter     7. 57.100 /  7. 57.100
> >   libswscale      5.  5.100 /  5.  5.100
> >   libswresample   3.  5.100 /  3.  5.100
> >   libpostproc    55.  5.100 / 55.  5.100
> > Input #0, matroska,webm, from 'l:\welter_originals\gamera the
> > brave\Latatude Zero-trailer.mkv':
> >   Metadata:
> >     encoder         : libmakemkv v1.15.0 (1.3.5/1.4.7) win(x64-release)
> >     creation_time   : 2020-03-05T18:41:29.000000Z
> >   Duration: 00:02:28.75, start: 0.000000, bitrate: 4685 kb/s
> >     Stream #0:0(eng): Video: mpeg2video (Main), 1 reference frame,
> > yuv420p(tv, top first, left), 720x480 [SAR 32:27 DAR 16:9], SAR 186:157
> DAR
> > 279:157, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc
> >     Metadata:
> >       BPS-eng         : 4488094
> >       DURATION-eng    : 00:02:28.748600000
> >       NUMBER_OF_FRAMES-eng: 3567
> >       NUMBER_OF_BYTES-eng: 83449382
> >       SOURCE_ID-eng   : 0100E0
> >       _STATISTICS_WRITING_APP-eng: MakeMKV v1.15.0 win(x64-release)
> >       _STATISTICS_WRITING_DATE_UTC-eng: 2020-03-05 18:41:29
> >       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
> > SOURCE_ID
> >     Stream #0:1(eng): Audio: ac3, 48000 Hz, mono, fltp, 192 kb/s
> (default)
> >     Metadata:
> >       title           : Mono
> >       BPS-eng         : 192000
> >       DURATION-eng    : 00:02:28.704000000
> >       NUMBER_OF_FRAMES-eng: 4647
> >       NUMBER_OF_BYTES-eng: 3568896
> >       SOURCE_ID-eng   : 0180BD
> >       _STATISTICS_WRITING_APP-eng: MakeMKV v1.15.0 win(x64-release)
> >       _STATISTICS_WRITING_DATE_UTC-eng: 2020-03-05 18:41:29
> >       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
> > SOURCE_ID
> > File 'test.mkv' already exists. Overwrite ? [y/N] y
> > [mpeg2_cuvid @ 000001ec985dfbc0] Initializing cuvid hwaccel
> > [mpeg2_cuvid @ 000001ec985dfbc0] CUVID capabilities for mpeg2_cuvid:
> > [mpeg2_cuvid @ 000001ec985dfbc0] 8 bit: supported: 1, min_width: 48,
> > max_width: 4080, min_height: 16, max_height: 4080
> > [mpeg2_cuvid @ 000001ec985dfbc0] 10 bit: supported: 0, min_width: 0,
> > max_width: 0, min_height: 0, max_height: 0
> > [mpeg2_cuvid @ 000001ec985dfbc0] 12 bit: supported: 0, min_width: 0,
> > max_width: 0, min_height: 0, max_height: 0
> > Stream mapping:
> >   Stream #0:0 -> #0:0 (mpeg2video (mpeg2_cuvid) -> h264 (h264_nvenc))
> >   Stream #0:1 -> #0:1 (copy)
> > Press [q] to stop, [?] for help
> > [mpeg2_cuvid @ 000001ec985dfbc0] Initializing cuvid hwaccel
> > [mpeg2_cuvid @ 000001ec985dfbc0] Formats: Original: cuda | HW: cuda | SW:
> > nv12
> > [graph 0 input from stream 0:0 @ 000001ec98632f00] w:720 h:480
> pixfmt:cuda
> > tb:1/1000 fr:30000/1001 sar:186/157 sws_param:flags=2
> > [h264_nvenc @ 000001ec985efe00] Loaded Nvenc version 10.0
> > [h264_nvenc @ 000001ec985efe00] Nvenc initialized successfully
> > Output #0, matroska, to 'test.mkv':
> >   Metadata:
> >     encoder         : Lavf58.29.100
> >     Stream #0:0(eng): Video: h264 (h264_nvenc) (Main), 1 reference frame
> > (H264 / 0x34363248), cuda(left), 720x480 [SAR 186:157 DAR 279:157],
> > q=-1--1, 2000 kb/s, 29.97 fps, 1k tbn, 29.97 tbc
> >     Metadata:
> >       BPS-eng         : 4488094
> >       DURATION-eng    : 00:02:28.748600000
> >       NUMBER_OF_FRAMES-eng: 3567
> >       NUMBER_OF_BYTES-eng: 83449382
> >       SOURCE_ID-eng   : 0100E0
> >       _STATISTICS_WRITING_APP-eng: MakeMKV v1.15.0 win(x64-release)
> >       _STATISTICS_WRITING_DATE_UTC-eng: 2020-03-05 18:41:29
> >       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
> > SOURCE_ID
> >       encoder         : Lavc58.54.100 h264_nvenc
> >     Side data:
> >       cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000
> vbv_delay:
> > -1
> >     Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, mono,
> > fltp, 192 kb/s (default)
> >     Metadata:
> >       title           : Mono
> >       BPS-eng         : 192000
> >       DURATION-eng    : 00:02:28.704000000
> >       NUMBER_OF_FRAMES-eng: 4647
> >       NUMBER_OF_BYTES-eng: 3568896
> >       SOURCE_ID-eng   : 0180BD
> >       _STATISTICS_WRITING_APP-eng: MakeMKV v1.15.0 win(x64-release)
> >       _STATISTICS_WRITING_DATE_UTC-eng: 2020-03-05 18:41:29
> >       _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
> > SOURCE_ID
> > [mpeg2_cuvid @ 000001ec985dfbc0] Initializing cuvid hwaccel2
> > bitrate=1805.6kbits/s speed=77.9x
> > [mpeg2_cuvid @ 000001ec985dfbc0] Formats: Original: cuda | HW: cuda | SW:
> > nv12
> > [graph 0 input from stream 0:0 @ 000001ec985e3a40] w:720 h:480
> pixfmt:cuda
> > tb:1/1000 fr:30000/1001 sar:186/157 sws_param:flags=2
> > [scaler_out_0_0 @ 000001ecac63f100] w:720 h:480 flags:'bicubic' interl:0
> > [auto_scaler_0 @ 000001ec986aed80] w:iw h:ih flags:'bicubic' interl:0
> > [scaler_out_0_0 @ 000001ecac63f100] auto-inserting filter 'auto_scaler_0'
> > between the filter 'Parsed_null_0' and the filter 'scaler_out_0_0'
> > Impossible to convert between the formats supported by the filter
> > 'Parsed_null_0' and the filter 'auto_scaler_0'
> > Error reinitializing filters!
> > Failed to inject frame into filter network: Function not implemented
> > Error while processing the decoded data for stream #0:0
> > [AVIOContext @ 000001ec985f1b00] Statistics: 0 seeks, 156 writeouts
> > [h264_nvenc @ 000001ec985efe00] Nvenc unloaded
> > [AVIOContext @ 000001ec985e3bc0] Statistics: 87142507 bytes read, 2 seeks
> > Conversion failed!
> >
> >
> Try this instead:
>
> ffmpeg -threads 1 -loglevel verbose -hwaccel cuvid
> -hwaccel_output_format cuda -c:v mpeg2_cuvid -extra_hw_frames 3 -i
> "l:\welter_originals\gamera the brave\Latatude Zero-trailer.mkv" -c:a copy
> -c:v h264_nvenc test.mkv
>
> Or with NVDEC:
>
> ffmpeg -threads 1 -loglevel verbose -hwaccel cuda
> -hwaccel_output_format cuda -extra_hw_frames 3 -i
> "l:\welter_originals\gamera the brave\Latatude Zero-trailer.mkv" -c:a copy
> -c:v h264_nvenc test.mkv
>
> See the hwaccel_output_format is set to cuda, and not the generic yuv420p.
>
> If you must use the yuv420p pixel format, then:
>
> (a). Unset -hwaccel_output_format option. When present, this disallows
> downloading textures to system memory.
>
> (b). Then use the hwdownload filter chained to the format=yuv420p. Note
> that this *might* not be supported, and may require you to use a planar
> pixel format such as nv12, depending on consequent filter chains.
>
> Note that doing so in your case would only decrease throughput, and is only
> necessary *if* you're using some software-based filter down the line, such
> as the generic overlay filter.
>
> Where possible, stick to either full H/W decode+encode, OR skip H/W decode
> entirely if the input format is likely to be unsupported by the underlying
> device.
> In the latter case, the use of the hwupload or hwupload_cuda filter(s) can
> then be used to create the required CUDA contexts for filters that depend
> on them, such as yadif_cuda, overlay_cuda, etc.
> Note that with hwupload filter, a device reference is required to upload
> hwframes to, typically via the -init_hw_device
> $device_type:$index=$identifier -filter_hw_device $identifier arguments,
> where $device_type in this  case would be cuda and $index would be the GPU
> to use for that session, and $identifier being a unique name to identify
> the hardware device by.
>
> Example:
>
> -init_hw_device cuda:0=hw -filter_hw_device hw
>
> Would initialize a device type cuda, using GPU index (from nvidia-smi) as 0
> (the first GPU), with the identifier passed to -filter_hw_device as hw.
>
> The filter hwupload_cuda initializes a device to use and does not require
> the manual step above. However, you can select *what* GPU to use by passing
> it directly to the filter, via:
>
> hwupload_cuda=$index
>
> To achieve the same result.
>
> On the -extra_hw_frames option and why its' needed for NVDEC (and CUVID),
> see this ticket: https://trac.ffmpeg.org/ticket/7562
>
> Recommended: Limit decoder threads to 1 as shown above to prevent NVDEC
> from misbehaving. It will outright warn you if thread count (or surface
> count in use) exceeds 16.
>
> Hope that helps.
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list