Search code examples
ffmpegnvencvp9

FFMPEG refuses to reencode vp9 via h264_nvenc


Using Windows, FFMPEG throws an error when reencoding vp9/opus .webm video into h264_nvenc/aac.

The issue is within trying to reencode via h264_nvenc, as using libx264 works just fine.

h264_nvenc works just fine when reencoding h264.

PS C:\Users\Уруру2\Videos> ffmpeg -i soad.webm -c:a aac -c:v h264_nvenc soad.mp4
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.1 (GCC) 20200726
  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-libsrt --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-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --enable-librav1e --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Input #0, matroska,webm, from 'soad.webm':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:05:07.70, start: -0.007000, bitrate: 14732 kb/s
    Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 7372x3024, SAR 1:1 DAR 1843:756, 23.98 fps, 23.98 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 00:05:07.682000000
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:05:07.701000000
File 'soad.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (opus (native) -> aac (native))
Press [q] to stop, [?] for help
[h264_nvenc @ 0000029fd34e3400] Width 7372 exceeds 4096
[h264_nvenc @ 0000029fd34e3400] No capable devices found
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
[aac @ 0000029fd34e4b40] Qavg: 12400.245
[aac @ 0000029fd34e4b40] 2 frames left in the queue on closing
Conversion failed!

Solution

  • The error happened not because of vp9, but rather the width of the video. h264_nvenc does not support width or height above 4096. My solution was to scale the video down from the original 7372x3024 to 3686x1512 using -vf parameter.

    The final command is

    ffmpeg -i soad.webm -c:a aac -c:v h264_nvenc -vf scale=3686:1512,setsar=1:1 soad.mp4