fifonik / FFMetrics

Visualizes Video Quality Metrics (PSNR, SSIM & VMAF) calculated by ffmpeg.exe
570 stars 22 forks source link

Error loading pkl model in the last version of ffmpeg #73

Closed Dikakus closed 2 years ago

Dikakus commented 2 years ago

Hi! First of all, thank you for your software.

I downloaded the last version of ffmpeg [ffmpeg-n5.0-latest-win64-gpl-5.0] and when I launch the command that the log file writes, the output says that the support for pkl files has been removed:

ffmpeg.exe -hide_banner -f lavfi -i color=c=black:s=640x480:d=1 -lavfi [0:v][0:v]libvmaf="model_path='C\:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.pkl'" -f null -

Input #0, lavfi, from 'color=c=black:s=640x480:d=1':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn
[libvmaf @ 0000024687a7d9c0] The "model_path" option is deprecated: use model='path=...'.
←[35mlibvmaf←[0m ←[31mERROR←[0m could not read model from path: "C:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.pkl"
←[35mlibvmaf←[0m ←[31mERROR←[0m support for pkl model files has been removed, use json
    Last message repeated 1 times
[Parsed_libvmaf_0 @ 0000024687af9200] problem loading model file: C:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.pkl
[AVFilterGraph @ 0000024687ae5440] Error initializing filter 'libvmaf' with args 'model_path=C\:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.pkl'
Error initializing complex filters.
Invalid argument

So it's not possible to run VMAF.

fifonik commented 2 years ago

Hi there. I've just tried FFMetrics with two Gyan's builds (ffmpeg-5.0-essentials_build.7z and ffmpeg-2022-01-27-git-3c831847a8-essentials_build.7z). Everything works as expected: image

So for me it looks like your issues is related to something else.

What version of FFMetrics do you use? Do you have json models in vmaf-models folder?

Dikakus commented 2 years ago

I've downloaded FFMetrics version 1.0:

image

The zip comes with vmaf-models (thank you about that):

image

It's quite weird. I've download the same version of ffmpeg than you (I was using the full version), and the error is still there. The log of FFMetrics throws two lines:

2022-01-30 21:35:57 ffmpeg.exe -nostdin -filters
2022-01-30 21:36:00 ffmpeg.exe -hide_banner -f lavfi -i color=c=black:s=640x480:d=1 -lavfi [0:v][0:v]libvmaf='C\:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.json' -f null -
2022-01-30 21:36:05 ffmpeg.exe -hide_banner -f lavfi -i color=c=black:s=640x480:d=1 -lavfi [0:v][0:v]libvmaf='C\:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.pkl' -f null -
2022-01-30 21:36:08 WARNING: VMAF metric initialization failed

If I launch the first one in the cmd console is ok, but the second one gives the error. I tried removing the vmaf_4k_v0.6.1.pkl file but then, fails vmaf_v0.6.1.pkl.

fifonik commented 2 years ago

The second one must not succeed with ffmpeg 5. FFMetrics is calling this on startup to check what type of model is supported by the installed version of ffrmpeg. So it should understand that json model supported and use it instead of pkl. Can you delete ffmetrics.log, run "ffmetrics -log-level=debug", exit program and share the ffmetrics.log?

Dikakus commented 2 years ago

Hi @fifonik! This is the log:

[deleted]

fifonik commented 2 years ago

This is the real issue:

2022-01-31 19:20:06 DEBUG: FF.ExecStatus.Started, -hide_banner -f lavfi -i color=c=black:s=640x480:d=1 -lavfi [0:v][0:v]libvmaf='C\:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.json' -f null - 2022-01-31 19:20:13 DEBUG: FF.ExecStatus.Finished. stdout: , stderr: Timed out(-2)

So while detecting what model type is supported, FFMetrics trying to execute ffmpeg.exe with json model provided and the call fails because of timeout on your system. This is why it is also checking if pkl models supported. Timeout is already quite high (5 seconds), so looks like your system if a bit under-powered (or something also happening in background, for example anti-virus is trying to scan ffmpeg.exe that is 80MB+).

I'd suggest to try ffmpeg shared instead of static (gyan provide it as well: ffmpeg-release-full-shared.7z). After first run ffmpeg DLLs will be loaded in memory and reused in the consecutive calls (FFMetrics is calling ffmpeg many times during process so it might be faster in your case. On my PC the difference is small, but when I tested on slow PC the difference was big. Personally I'm using shared ffmpeg build system wide and testing with different static builds that I'm putting locally).

Unfortunately, I do not have any other suggestion. Sorry. P.S. I will add an options for configuring timeouts run time.

Dikakus commented 2 years ago

Oh, I was so obsessed with the message about removing pkl files from the libvmaf that I didn't realize the timeout message.

I run the ffmpeg test with the Measure-command cmlet from PowerShell

Measure-command {ffmpeg.exe -hide_banner -f lavfi -i color=c=black:s=640x480:d=1 -lavfi [0:v][0:v]libvmaf="C\\:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.json" -f null -}

And it reports 3 seconds more or less:

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 3
Milliseconds      : 324
Ticks             : 23247034
TotalDays         : 2,69062893518519E-05
TotalHours        : 0,000645750944444444
TotalMinutes      : 0,0387450566666667
TotalSeconds      : 2,3247034
TotalMilliseconds : 2324,7034

However, I've followed your recommendation and I've downloaded the shared version of ffmpeg and now I can tick the VMAF test.

image

So, great then! Thank you for your time, and maybe setting timouts like a configuration is a good idea.

fifonik commented 2 years ago

Could you measure execution time for shared build and share results please? Thanks.

Dikakus commented 2 years ago

¡Of course! I've noticed that the first time I lauch ffmpeg it takes longer. Maybe in the second one there is something cached in memory.

With static version:

Measure-command {.\ffmpeg-n5.0-latest-win64-gpl-5.0\bin\ffmpeg.exe -f lavfi -i color=c=black:s=640x480:d=1 -lavfi [0:v][0:v]libvmaf="C\\:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.json" -f null -}

First run:

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 6
Milliseconds      : 749
Ticks             : 67499574
TotalDays         : 7,81245069444444E-05
TotalHours        : 0,00187498816666667
TotalMinutes      : 0,11249929
TotalSeconds      : 6,7499574
TotalMilliseconds : 6749,9574

Second run:

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 2
Milliseconds      : 472
Ticks             : 24729050
TotalDays         : 2,86215856481481E-05
TotalHours        : 0,000686918055555556
TotalMinutes      : 0,0412150833333333
TotalSeconds      : 2,472905
TotalMilliseconds : 2472,905

With shared libraries:

Measure-command {.\ffmpeg-n5.0-latest-win64-gpl-shared-5.0\bin\ffmpeg.exe -f lavfi -i color=c=black:s=640x480:d=1 -lavfi [0:v][0:v]libvmaf="C\\:/Portables/FFMetrics/vmaf-models/vmaf_4k_v0.6.1.json" -f null -}

First run:

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 9
Milliseconds      : 631
Ticks             : 96317864
TotalDays         : 0,000111479009259259
TotalHours        : 0,00267549622222222
TotalMinutes      : 0,160529773333333
TotalSeconds      : 9,6317864
TotalMilliseconds : 9631,7864

Second run:

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 2
Milliseconds      : 316
Ticks             : 23164522
TotalDays         : 2,68107893518518E-05
TotalHours        : 0,000643458944444444
TotalMinutes      : 0,0386075366666667
TotalSeconds      : 2,3164522
TotalMilliseconds : 2316,4522