Log in

View Full Version : ERROR using NNEDI in FFMPEG


N.ROM.anova
12th October 2019, 20:41
I’ve been testing the various deinterlacing filters in FFMPEG, and no matter what I try, NNEDI fails to initialize.

NNEDI requires the use of a binary filter file for the “weights”, which FFMPEG provides a link to here:
https://github.com/dubhater/vapoursynth-nnedi3/blob/master/src/nnedi3_weights.bin

Problem is there are NO instructions on where to install this file in relation to FFMPEG. I’ve tried placing the file in the main FFMPEG folder, as well as in the various sub folders. Nothing works, as FFMPEG is unable to locate the weights file and keeps giving the following error message:

[mpeg2video @ 000001a1b34f0740] ignoring pic cod ext after 0
[Parsed_nnedi_1 @ 000001a1b39b4ac0] No weights file provided, aborting!
[AVFilterGraph @ 000001a1b3aa2b80] Error initializing filter 'nnedi' with args'weights=./nnedi3_weights.bin:deint=interlaced'
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!

The FFMPEG formula I'm using is:
ffmpeg -i SC_EP-08.mp4 -c:v libx264 -preset ultrafast -tune animation -crf 1 -vf "fieldmatch,nnedi=weights='./nnedi3_weights.bin':deint=interlaced,decimate" -acodec copy ivtc_TEST-07_SC_EP-08.mp4

In the code above, I’ve listed the location of the weights file as “./”. The only place I could find a formula for using NNEDI with FFMPEG was here:
https://github.com/kfrn/ffmpeg-things/blob/master/deinterlacing.md

In that article they list the location for the weights file in the formula as “./”. I’m not sure what that location means. I’ve tried removing the “./” in the call, as well as inputting the direct file URL for the weights file on my machine. Nothing works. I keep getting the same error message.

I’ve been able to do all other types of editing, conversion, encoding, etc. in FFMPEG. It is just NNEDI that is giving me issues. What am I doing wrong?

NOTE: I need to get NNEDI working in FFMPEG, NOT AVIsynth, as I’m editing and encoding with MP4 files only.

StainlessS
12th October 2019, 21:41
".\" or "./" is current directory, maybe specify full path to it eg "D:\\nnedi=weights='./nnedi3_weights.bin".
If ffmpeg.exe is being used via PATH environment variable, then perhaps current directory is relative to that (Ie same directory as ffmpeg.exe).
Or, maybe is relative to current directory of calling script/cmd/bat file.

So, just to test out that it does work at all, try fullpath, eg (put it in "D:\").

ffmpeg -i SC_EP-08.mp4 -c:v libx264 -preset ultrafast -tune animation -crf 1 -vf "fieldmatch,nnedi=weights='D:/nnedi3_weights.bin':deint=interlaced,decimate" -acodec copy ivtc_TEST-07_SC_EP-08.mp4


good luck.

EDIT: see here:- https://forum.videohelp.com/threads/381126-ffmpeg-1080i50-to-720p#post2465082
Look like maybe mistake in your command, ie not

nnedi=weights='./nnedi3_weights.bin'
or
nnedi=weights='D:/nnedi3_weights.bin'

but

nnedi='./nnedi3_weights.bin'
or
nnedi='D:/nnedi3_weights.bin'


EDIT: Its used here under linux, but its not clear whether it is a path or not:- https://forum.shotcut.org/t/technical-discussion-interlacing-revisited/8311/35

EDIT: Maybe you were correct after all (although it has no path, may not be a filename, just a name):-

[21:39:08 CEST] <furq> you need the weights file listed there
[21:39:25 CEST] <furq> or alternatively just use yadif, it's much faster and it looks reasonably good
[21:39:51 CEST] <furq> but yeah if you do use nnedi then -vf nnedi=weights=nnedi3_weights.bin


Similar question was already asked on Doom9, got no replies at all.

StainlessS
12th October 2019, 23:28
This works (well dont crash or throw error, I did not have an interlaced clip handy and did not wait till completion).

With "nnedi3_weights.bin" in root of windows "D:\" drive, and test command file in "D:\Test.Cmd"
FFMpeg.Exe in "C:\BIN\", and system environment has "C:\BIN\" added to PATH variable.

D:\Test.Cmd

ffmpeg -i Parade.avi -c:v libx264 -vf "nnedi=nnedi3_weights.bin,format=yuv420p" -preset fast -crf 23 out.mp4


From CLI in root of "D:\", I ran Test.Cmd,

Did not work when I tried with "nnedi3_weights.bin" in "C:\BIN", same directory as FFMPEG.


EDIT: This forum is bloody awful for entering backSlash, they get swallowed up when not in code block, you gotta keep entering two backslashes,
and if you edit, you gotta go back and replace all of the double backslashes again.

It seems that when ffmpeg docs use "nnedi=weight", the weight part is just a placeholder for "nnedi3_weights.bin", and where name should be inserted,
dont know if it is intended to be a filename with path (I did not get it to work with a path).

EDIT: It was real slow (no way that slow in Avisnyth, I'm gettin 3.8 FPS, 480x360 clip, on Core Duo 2.88GHz [maybe I did something wrong]).

N.ROM.anova
13th October 2019, 00:23
THANK YOU StainlessS! That did the trick!

So the simplified answer for anyone else looking for a solution is that the NNEDI weights file has to be saved on the same drive where the files being converted are also stored. The bin file can be placed into either the same directory or at the root. the NNEDI weights file will not work if it is on the same drive that FFMPEG is installed in (or so it seems at this point in time).

If placing the files in the same directory, then the weights part of the NNEDI command is:
nnedi=weights='./nnedi3_weights.bin'"

If placing them in the root, then the weights part of the NNEDI is:
nnedi=weights='nnedi3_weights.bin'