Impossible to convert between the formats supported by the filter '...' - Error reinitializing filters

Viewed 20451

I am using this ffmpeg command(values removed for simplicity)

ffmpeg -hwaccel cuvid -c:v h264_cuvid -y -ss 1 -i "FILE0001.MOV" -ss 0 -i "GOPR0621.MP4" -filter_complex 
[0:v][1:v]
  midequalizer
[al];
[al]
  yadif
  lenscorrection
  scale
[vl];
[1:v]
  lenscorrection
  scale
[vr];
[vl][vr]
  hstack=shortest=1 
-an -c:v h264_nvenc -preset slow "output.mp4"

on a machine with a cuda graphics card.

I get

ffmpeg version N-90979-g08032331ac Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  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. 18.100 / 56. 18.100
  libavcodec     58. 19.100 / 58. 19.100
  libavformat    58. 13.101 / 58. 13.101
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 21.100 /  7. 21.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000254a8afc0c0] st: 0 edit list: 1 Missing key frame while searching for timestamp: 6006
[mov,mp4,m4a,3gp,3g2,mj2 @ 00000254a8afc0c0] st: 0 edit list 1 Cannot find an index entry before timestamp: 6006.
....
Stream mapping:
  Stream #0:0 (h264_cuvid) -> midequalizer:in0
  Stream #1:0 (h264) -> midequalizer:in1
  Stream #1:0 (h264) -> lenscorrection
  hstack -> Stream #0:0 (h264_nvenc)
  
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!

The same command without CUDA works, ie

ffmpeg -y -ss 1 -i "FILE0001.MOV" -ss 0 -i "GOPR0621.MP4" -filter_complex 
[0:v][1:v]
  midequalizer
[al];
[al]
  yadif
  lenscorrection
  scale
[vl];
[1:v]
  lenscorrection
  scale
[vr];
[vl][vr]
  hstack=shortest=1 
-an "output.mp4"

How do I make it work on a Windows 10 machine with cuda?

4 Answers

solution as of 2020: you need to pass hwupload_cuda along with the filter to explicitly tell FFmpeg what to do.

So your command should look like this:

ffmpeg -hwaccel cuvid -c:v h264_cuvid -vsync 0 -y -i input.mp4 -vf "hwupload_cuda,scale_npp=w=1280:h=-2" -c:v h264_nvenc ...

Detail about this issue is described here: https://trac.ffmpeg.org/ticket/5587

Don't have a CUDA device to test with, but it should be

ffmpeg -hwaccel cuvid -c:v h264_cuvid -y -ss 1 -i "FILE0001.MOV" -ss 0 -i "GOPR0621.MP4" -filter_complex 
[0:v]hwdownload,format=nv12,format=yuv420p[0v];
[0v][1:v]
  midequalizer
[al];
[al]
  yadif
  lenscorrection
  scale
[vl];
[1:v]
  lenscorrection
  scale
[vr];
[vl][vr]
  hstack=shortest=1 
-an -c:v h264_nvenc -preset slow "output.mp4"

Don't use cuvid, it is not better decoder in 2020. Just allow ffmpeg to choose the decoder by himself. You need specifie that you are want to use hardware acceleration.

Your piplene should looks like:

ffmpeg -hwaccel nvdec -hwaccel_device 0 -hwaccel_output_format cuda -i input_file.mp4 -map 0:0 -map 0:1 -c:v:0 h264_nvenc -b:v:0 650000 -filter:v:0 scale_npp=-2:360:interp_algo=super,hwdownload,format=nv12 -c:a:0 aac -b:a:0 96000 -ac:a:0 2 -max_muxing_queue_size 9999 -movflags +faststart -f mp4 /home/uploads/tmp.mp4

I got it to work by limiting the number of threads used for encoding.

"-threads 9" and lower worked, "-threads 10" or above failed with the error.

Related