NVENC encoding with Windows10

Questions involving a Windows version of FFmpeg.
Post Reply
krypt87
Posts: 7
Joined: Wed Oct 10, 2018 2:02 pm

NVENC encoding with Windows10

Post by krypt87 » Wed Oct 10, 2018 2:06 pm

Hey guys,

I had to reinstall windows 10 because windows. I have this exact same code working prior to the reinstall, however after I cant get it to work.

I am using the latest Nvidia Drivers 416.16
I have VisualStudio 2017 and Cuda Toolkit 10.0.130 411.31 installed
2x 1080TIs

Using ffmpeg 4.0.2:

Code: Select all

T:\ffmpeg\bin\4.0.2\ffmpeg.exe -c:v h264_cuvid -i "T:\Streams\01-ready\2018-10-10 21-19-21.mp4" -i "T:\Streams\10-source\kpg-logo.png" -filter_complex "overlay=10:10" -b:v 24000k -c:v h264_nvenc -c:a copy "T:\Streams\02-encoded\2018-10-10 21-19-21_watermarked.mp4"
Output:

Code: Select all

ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.1 (GCC) 20180722
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --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
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'T:\Streams\01-ready\2018-10-10 21-19-21.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.84.100
  Duration: 00:28:41.71, start: 0.000000, bitrate: 24422 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/unknown/unknown), 2560x1440, 24130 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 286 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, png_pipe, from 'T:\Streams\10-source\kpg-logo.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgba(pc), 2560x1440 [SAR 2834:2834 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (h264_cuvid) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  overlay -> Stream #0:0 (h264_nvenc)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[h264_nvenc @ 000002851a001940] CreateInputBuffer failed: out of memory (10)
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!
Press any key to continue . . .

Code: Select all

[h264_nvenc @ 000002851a001940] CreateInputBuffer failed: out of memory (10)
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!
Any ideas?

krypt87
Posts: 7
Joined: Wed Oct 10, 2018 2:02 pm

Re: NVENC encoding with Windows10

Post by krypt87 » Sun Oct 14, 2018 1:33 pm

I have made a few changes and got a bit further but still no love:

Code: Select all

T:\ffmpeg\bin\4.0.2\ffmpeg.exe -loglevel 48 -y -hwaccel_device 1 -hwaccel cuvid -c:v h264_cuvid -i "T:\Streams\01-ready\2018-10-11 01-36-26_watermarked.mp4" -i "T:\Streams\10-source\kpg-logo-2560x1440.png" -filter_complex "overlay=0:0,hwdownload,format=pix_fmts=yuv420p" -b:v 24000k -c:v h264_nvenc -c:a copy -pixel_format yuv240p "T:\Streams\02-encoded\2018-10-11 01-36-26_watermarked_watermarked.mp4"
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.1 (GCC) 20180722
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --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
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '48'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-hwaccel_device' ... matched as option 'hwaccel_device' (select a device for HW acceleration) with argument '1'.
Reading option '-hwaccel' ... matched as option 'hwaccel' (use HW accelerated decoding) with argument 'cuvid'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_cuvid'.
Reading option '-i' ... matched as input url with argument 'T:\Streams\01-ready\2018-10-11 01-36-26_watermarked.mp4'.
Reading option '-i' ... matched as input url with argument 'T:\Streams\10-source\kpg-logo-2560x1440.png'.
Reading option '-filter_complex' ... matched as option 'filter_complex' (create a complex filtergraph) with argument 'overlay=0:0,hwdownload,format=pix_fmts=yuv420p'.
Reading option '-b:v' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '24000k'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_nvenc'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-pixel_format' ... matched as AVOption 'pixel_format' with argument 'yuv240p'.
Reading option 'T:\Streams\02-encoded\2018-10-11 01-36-26_watermarked_watermarked.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument 48.
Applying option y (overwrite output files) with argument 1.
Applying option filter_complex (create a complex filtergraph) with argument overlay=0:0,hwdownload,format=pix_fmts=yuv420p.
Successfully parsed a group of options.
Parsing a group of options: input url T:\Streams\01-ready\2018-10-11 01-36-26_watermarked.mp4.
Applying option hwaccel_device (select a device for HW acceleration) with argument 1.
Applying option hwaccel (use HW accelerated decoding) with argument cuvid.
Applying option c:v (codec name) with argument h264_cuvid.
Successfully parsed a group of options.
Opening an input file: T:\Streams\01-ready\2018-10-11 01-36-26_watermarked.mp4.
[NULL @ 00000182149bb780] Opening 'T:\Streams\01-ready\2018-10-11 01-36-26_watermarked.mp4' for reading
[file @ 00000182149bcf00] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] Processing st: 0, edit list 0 - media time: 0, duration: 115722
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] Processing st: 1, edit list 0 - media time: 1024, duration: 358401
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] drop a frame at curr_cts: 0 @ 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] Before avformat_find_stream_info() pos: 24011537 bytes read:42986 seeks:1 nb_streams:2
[h264 @ 00000182149ce040] nal_unit_type: 7, nal_ref_idc: 3
[h264 @ 00000182149ce040] nal_unit_type: 8, nal_ref_idc: 3
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] demuxer injecting skip 1024 / discard 0
[aac @ 00000182149c4880] skip 1024 / discard 0 samples due to side data
[h264 @ 00000182149ce040] nal_unit_type: 6, nal_ref_idc: 0
    Last message repeated 1 times
[h264 @ 00000182149ce040] nal_unit_type: 5, nal_ref_idc: 3
[h264 @ 00000182149ce040] ct_type:0 pic_struct:0
[h264 @ 00000182149ce040] Format yuv420p chosen by get_format().
[h264 @ 00000182149ce040] Reinit context to 2560x1440, pix_fmt: yuv420p
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000182149bb780] After avformat_find_stream_info() pos: 125355 bytes read:168293 seeks:2 frames:2
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'T:\Streams\01-ready\2018-10-11 01-36-26_watermarked.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.12.100
  Duration: 00:00:08.15, start: 0.000000, bitrate: 23566 kb/s
    Stream #0:0(und), 1, 1/15360: Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 2560x1440 [SAR 1:1 DAR 16:9], 0/1, 25315 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und), 1, 1/44100: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 159 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Successfully opened the file.
Parsing a group of options: input url T:\Streams\10-source\kpg-logo-2560x1440.png.
Successfully parsed a group of options.
Opening an input file: T:\Streams\10-source\kpg-logo-2560x1440.png.
[NULL @ 0000018214a37080] Opening 'T:\Streams\10-source\kpg-logo-2560x1440.png' for reading
[file @ 0000018215231d80] Setting default whitelist 'file,crypto'
[png_pipe @ 0000018214a37080] Format png_pipe probed with size=2048 and score=99
[png_pipe @ 0000018214a37080] Before avformat_find_stream_info() pos: 0 bytes read:32768 seeks:0 nb_streams:1
[png_pipe @ 0000018214a37080] After avformat_find_stream_info() pos: 64134 bytes read:64134 seeks:0 frames:1
Input #1, png_pipe, from 'T:\Streams\10-source\kpg-logo-2560x1440.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0, 1, 1/25: Video: png, 1 reference frame, rgba(pc), 2560x1440 [SAR 2795:2795 DAR 16:9], 0/1, 25 tbr, 25 tbn, 25 tbc
Successfully opened the file.
[Parsed_overlay_0 @ 0000018214a35140] Setting 'x' to value '0'
[Parsed_overlay_0 @ 0000018214a35140] Setting 'y' to value '0'
[Parsed_format_2 @ 0000018214a35780] Setting 'pix_fmts' to value 'yuv420p'
Parsing a group of options: output url T:\Streams\02-encoded\2018-10-11 01-36-26_watermarked_watermarked.mp4.
Applying option b:v (video bitrate (please use -b:v)) with argument 24000k.
Applying option c:v (codec name) with argument h264_nvenc.
Applying option c:a (codec name) with argument copy.
Successfully parsed a group of options.
Opening an output file: T:\Streams\02-encoded\2018-10-11 01-36-26_watermarked_watermarked.mp4.
[file @ 000001821502e040] Setting default whitelist 'file,crypto'
Successfully opened the file.
[h264_cuvid @ 000001821522fb80] Initializing cuvid hwaccel
[AVHWDeviceContext @ 00000182152309c0] Loaded lib: nvcuda.dll
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuInit
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuDeviceGetCount
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuDeviceGet
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuDeviceGetName
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuDeviceComputeCapability
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuCtxCreate_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuCtxSetLimit
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuCtxPushCurrent_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuCtxPopCurrent_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuCtxDestroy_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuMemAlloc_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuMemFree_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuMemcpy2D_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuMemcpy2DAsync_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuGetErrorName
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuGetErrorString
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuStreamCreate
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuStreamQuery
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuStreamSynchronize
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuStreamDestroy_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuStreamAddCallback
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuEventCreate
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuEventDestroy_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuEventSynchronize
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuEventQuery
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuEventRecord
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuGLGetDevices_v2
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuGraphicsGLRegisterImage
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuGraphicsUnregisterResource
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuGraphicsMapResources
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuGraphicsUnmapResources
[AVHWDeviceContext @ 00000182152309c0] Loaded sym: cuGraphicsSubResourceGetMappedArray
[h264_cuvid @ 000001821522fb80] Initializing CUDA frames context: sw_format = nv12, width = 2560, height = 1440
[h264_cuvid @ 000001821522fb80] Format cuda chosen by get_format().
[h264_cuvid @ 000001821522fb80] Loaded lib: nvcuvid.dll
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidGetDecoderCaps
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidCreateDecoder
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidDestroyDecoder
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidDecodePicture
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidMapVideoFrame64
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidUnmapVideoFrame64
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidCtxLockCreate
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidCtxLockDestroy
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidCtxLock
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidCtxUnlock
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidCreateVideoSource
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidCreateVideoSourceW
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidDestroyVideoSource
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidSetVideoSourceState
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidGetVideoSourceState
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidGetSourceVideoFormat
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidGetSourceAudioFormat
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidCreateVideoParser
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidParseVideoData
[h264_cuvid @ 000001821522fb80] Loaded sym: cuvidDestroyVideoParser
[h264_cuvid @ 000001821522fb80] CUVID capabilities for h264_cuvid:
[h264_cuvid @ 000001821522fb80] 8 bit: supported: 1, min_width: 48, max_width: 4096, min_height: 16, max_height: 4096
[h264_cuvid @ 000001821522fb80] 10 bit: supported: 0, min_width: 0, max_width: 0, min_height: 0, max_height: 0
[h264_cuvid @ 000001821522fb80] 12 bit: supported: 0, min_width: 0, max_width: 0, min_height: 0, max_height: 0
detected 20 logical cores
Stream mapping:
  Stream #0:0 (h264_cuvid) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  format -> Stream #0:0 (h264_nvenc)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
    Last message repeated 3 times
[h264_cuvid @ 000001821522fb80] Initializing cuvid hwaccel
[h264_cuvid @ 000001821522fb80] Initializing CUDA frames context: sw_format = nv12, width = 2560, height = 1440
[h264_cuvid @ 000001821522fb80] Format cuda chosen by get_format().
[h264_cuvid @ 000001821522fb80] Formats: Original: cuda | HW: cuda | SW: nv12
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
    Last message repeated 6 times
[Parsed_overlay_0 @ 0000018215026100] Setting 'x' to value '0'
[Parsed_overlay_0 @ 0000018215026100] Setting 'y' to value '0'
[Parsed_format_2 @ 0000018215024cc0] Setting 'pix_fmts' to value 'yuv420p'
[graph 0 input from stream 0:0 @ 000001821501d940] Setting 'video_size' to value '2560x1440'
[graph 0 input from stream 0:0 @ 000001821501d940] Setting 'pix_fmt' to value '119'
[graph 0 input from stream 0:0 @ 000001821501d940] Setting 'time_base' to value '1/15360'
[graph 0 input from stream 0:0 @ 000001821501d940] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 000001821501d940] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 000001821501d940] Setting 'frame_rate' to value '60/1'
[graph 0 input from stream 0:0 @ 000001821501d940] w:2560 h:1440 pixfmt:cuda tb:1/15360 fr:60/1 sar:1/1 sws_param:flags=2
[graph 0 input from stream 1:0 @ 000001821501ea40] Setting 'video_size' to value '2560x1440'
[graph 0 input from stream 1:0 @ 000001821501ea40] Setting 'pix_fmt' to value '26'
[graph 0 input from stream 1:0 @ 000001821501ea40] Setting 'time_base' to value '1/25'
[graph 0 input from stream 1:0 @ 000001821501ea40] Setting 'pixel_aspect' to value '2795/2795'
[graph 0 input from stream 1:0 @ 000001821501ea40] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 1:0 @ 000001821501ea40] Setting 'frame_rate' to value '25/1'
[graph 0 input from stream 1:0 @ 000001821501ea40] w:2560 h:1440 pixfmt:rgba tb:1/25 fr:25/1 sar:2795/2795 sws_param:flags=2
[format @ 00000182149f4c80] Setting 'pix_fmts' to value 'yuv420p|nv12|p010le|yuv444p|p016le|yuv444p16le|bgr0|rgb0|cuda|d3d11'
[auto_scaler_0 @ 0000018214a2a140] w:iw h:ih flags:'bilinear' interl:0
[Parsed_overlay_0 @ 0000018215026100] auto-inserting filter 'auto_scaler_0' between the filter 'graph 0 input from stream 0:0' and the filter 'Parsed_overlay_0'
Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0: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 #1:0
[AVIOContext @ 000001821502e140] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 00000182149c51c0] Statistics: 688181 bytes read, 2 seeks
[AVIOContext @ 0000018215231e40] Statistics: 64134 bytes read, 0 seeks
Conversion failed!
Press any key to continue . . .

hydra3333
Posts: 199
Joined: Sun Apr 28, 2013 1:03 pm
Contact:

Re: NVENC encoding with Windows10

Post by hydra3333 » Mon Oct 15, 2018 1:10 am

don't know sorry. just out of interest, what happens
1. when you omit the cuvid stuff and just do the encode with nvenc
2. when you use the latest ffmpeg build

krypt87
Posts: 7
Joined: Wed Oct 10, 2018 2:02 pm

Re: NVENC encoding with Windows10

Post by krypt87 » Mon Oct 15, 2018 9:20 am

1. when you omit the cuvid stuff and just do the encode with nvenc
Same error, Out of RAM
when you use the latest ffmpeg build
Already using the latest less the nightly builds

krypt87
Posts: 7
Joined: Wed Oct 10, 2018 2:02 pm

Re: NVENC encoding with Windows10

Post by krypt87 » Mon Oct 15, 2018 10:21 am

Even trying the simplest of things:

Code: Select all

ffmpeg.exe -y -hwaccel cuvid -c:v h264_cuvid -i "input" -c:v h264_nvenc -preset slow "output.mp4"
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.1 (GCC) 20180722
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --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
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'T:\Streams\01-ready\2018-10-15 20-49-44.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.84.100
  Duration: 00:00:10.64, start: 0.000000, bitrate: 22978 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/unknown/unknown), 2560x1440, 24216 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 156 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mp4, to 'T:\Streams\02-encoded\2018-10-15 20-49-44.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.12.100
    Stream #0:0(und): Video: h264 (h264_nvenc) (Main) (avc1 / 0x31637661), cuda, 2560x1440 [SAR 1:1 DAR 16:9], q=-1--1, 2000 kb/s, 60 fps, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.18.100 h264_nvenc
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: -1
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc58.18.100 aac
[h264_cuvid @ 000001a99033b600] ctx->cvdl->cuvidMapVideoFrame(ctx->cudecoder, parsed_frame.dispinfo.picture_index, &mapped_frame, &pitch, &params) failed -> CUDA_ERROR_UNKNOWN: unknown error
Error while decoding stream #0:0: Generic error in an external library
/* repeated many many times */
[h264_nvenc @ 000001a98fcfc100] Failed locking bitstream buffer: invalid param (8)
video encoding failed: Invalid argument
[aac @ 000001a98fdcd380] Qavg: 64894.355
[aac @ 000001a98fdcd380] 2 frames left in the queue on closing
Conversion failed!
Press any key to continue . . .

vayvanne
Posts: 20
Joined: Thu Jul 03, 2014 10:49 pm

Re: NVENC encoding with Windows10

Post by vayvanne » Mon Oct 15, 2018 2:34 pm


krypt87
Posts: 7
Joined: Wed Oct 10, 2018 2:02 pm

Re: NVENC encoding with Windows10

Post by krypt87 » Wed Oct 17, 2018 1:13 pm

yeah, made no difference

krypt87
Posts: 7
Joined: Wed Oct 10, 2018 2:02 pm

Re: NVENC encoding with Windows10

Post by krypt87 » Wed Oct 17, 2018 3:23 pm

With alot of hair pulling and teeth grinding, I finally have a working solution.

Code: Select all

REM windows batch file
set ffmpegversion=20181015-c27c7b4-win64-static

set sourcedir=T:\Streams\01-ready
set outputdir=T:\Streams\02-encoded
set finaldir=T:\Streams\03-upload

set libdir=T:\ffmpeg\bin\%ffmpegversion%

set introvid=T:\Streams\10-source\kpg-intro-10pec-audio.mp4
set watermark=T:\Streams\10-source\kpg-logo.png
set introvidlen=3.00
set outputbitrate=24000

set ffmpegdefaults=-loglevel 40 -hide_banner
set ffmpegaccels=-hwaccel_device 1 -hwaccel cuvid -c:v h264_cuvid
set ffmpegaccele=-c:v h264_nvenc

cd /d %libdir%

if not exist %outputdir% (
	mkdir %outputdir%
)

if not exist %finaldir% (
	mkdir %finaldir%
)

setlocal enabledelayedexpansion
@echo Checking %sourcedir%\*.mp4
for %%f in (%sourcedir%\*.mp4) do (	
	set encodeWatermark=0
	set encodeIntro=0
	
	set execWatermark=%libdir%\ffmpeg.exe -y %ffmpegdefaults% %ffmpegaccels% -i "%%f" -i "%watermark%" -filter_complex "hwdownload,format=nv12,overlay=0:0,hwupload_cuda" -b:v %outputbitrate%k %ffmpegaccele% -c:a copy "%outputdir%\%%~nf_watermarked.mp4"
	
	set filter1=[0:v]format=pix_fmts=yuv420p, trim=start=0:end=%introvidlen%,setpts=PTS-STARTPTS[firstclip]; 
	set filter2=[1:v]format=pix_fmts=yuv420p, trim=start=1,setpts=PTS-STARTPTS[secondclip]; 
    	set filter3=[0:v]format=pix_fmts=yuv420p, trim=start=%introvidlen%,setpts=PTS-STARTPTS[fadeoutsrc]; 
	set filter4=[1:v]format=pix_fmts=yuv420p, trim=start=0:end=1,setpts=PTS-STARTPTS[fadeinsrc]; 
	set filter5=[fadeinsrc]format=pix_fmts=yuva420p, fade=t=in:st=0:d=2:alpha=1[fadein]; 
	set filter6=[fadeoutsrc]format=pix_fmts=yuva420p, fade=t=out:st=3:d=2:alpha=1[fadeout]; 
	set filter7=[fadein]fifo[fadeinfifo]; 
	set filter8=[fadeout]fifo[fadeoutfifo]; 
	set filter9=[fadeoutfifo][fadeinfifo]overlay[crossfade]; 
	set filter10=[firstclip][crossfade][secondclip]concat=n=3[output]; 
	set filter11=[0:a][1:a] acrossfade=d=1 [audio]
	
	set execIntro=%libdir%\ffmpeg.exe -y %ffmpegdefaults% -i "%introvid%" -i "%outputdir%\%%~nf_watermarked.mp4" -filter_complex "!filter1!!filter2!!filter3!!filter4!!filter5!!filter6!!filter7!!filter8!!filter9!!filter10!!filter11!" -map "[output]" -map "[audio]" -b:v %outputbitrate%k %ffmpegaccele% "%outputdir%\%%~nf_ready.mp4"

	if exist "%outputdir%\%%~nf_watermarked.mp4" (
		@ECHO %outputdir%\%%~nf_watermarked.mp4 exists
		for %%A in ("%outputdir%\%%~nf_watermarked.mp4") do (
			if %%~zA==0 (
				@ECHO %outputdir%\%%~nf_watermarked.mp4 is zero filesize
				set encodeWatermark=1
			) ELSE (
				@ECHO %outputdir%\%%~nf_watermarked.mp4 is non-zero filesize
			)
		)
	) ELSE (
		@ECHO %outputdir%\%%~nf_watermarked does not exist
		set encodeWatermark=1
	)
	
	if !encodeWatermark!==1 (
		@ECHO Executing !execWatermark!
		CD /d T:\Streams\10-source
		CALL !execWatermark!
	)

	if exist "%outputdir%\%%~nf_ready.mp4" (
		@ECHO %outputdir%\%%~nf_ready.mp4 exists
		for %%A in ("%outputdir%\%%~nf_ready.mp4") do (
			if %%~zA==0 (
				@ECHO %outputdir%\%%~nf_ready.mp4 is zero filesize
				set encodeIntro=1
			) ELSE (
				@ECHO %outputdir%\%%~nf_ready.mp4 is non-zero filesize
			)
		)
	) ELSE (
		@ECHO %outputdir%\%%~nf_ready does not exist
		set encodeIntro=1
	)
	
	if !encodeIntro!==1 (
		@ECHO Executing !execIntro!
		CD /d T:\Streams\10-source
		CALL !execIntro!
	)

	if not exist "%finaldir%\%%~nf.mp4" (
		@ECHO Copy %outputdir%\%%~nf_ready.mp4 to %finaldir%\%%~nf.mp4
		COPY "%outputdir%\%%~nf_ready.mp4" "%finaldir%\%%~nf.mp4"
		TIMEOUT 2
	)
)
I'm sure its possible to do both the crossfade and the watermarking in 1 run, but I have spent enough time just getting this working. Not the prettiest, but its function.

pandy
Posts: 223
Joined: Mon Feb 24, 2014 1:46 pm

Re: NVENC encoding with Windows10

Post by pandy » Sat Nov 17, 2018 12:50 pm

Your issue was RGBA format called explicitly and later not converting it to format supported by NVEnc. - all information is present in provided log - it is recommended to read logs.

Post Reply
'