libvmaf encountered an error, check log for details
georgedorn opened this issue · 8 comments
First of all, thanks for this; I was just about to get started building something just like this when I found your post on reddit; saved me a ton of time that would get me 25% as far as you have.
Anyway, a bug which I think might just be a version problem. Does this need a specific version of ffmpeg, built against a specific version of libvmaf? I just built ffmpeg and libvmaf using the latest versions of each (ffmpeg-4.3.1 and vmaf-2.0.0) and I'm getting a libvmaf error:
python main.py -ovp inputfile.mp4 -crf 16 18 20 22 24 --interval 120 --clip-length 2
-----------------------------------------------------------------------------------------------------------
Here's some information about the original video:
Filename: input.mp4
Bitrate: 16318 kbit/s
Framerate: 30000/1001 (29.97) FPS
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
Creating a 2 second clip every 120 seconds from /home/user/workspace/video-quality-metrics/input.mp4...
-----------------------------------------------------------------------------------------------------------
Creating clip 1 which starts at 00:02:00...
frame= 59 fps=0.0 q=-1.0 Lsize= 49995kB time=00:00:01.97 bitrate=207896.8kbits/s speed=2.61x
Creating clip 2 which starts at 00:04:00...
frame= 60 fps=0.0 q=-1.0 Lsize= 29043kB time=00:00:01.97 bitrate=120773.8kbits/s speed=3.01x
Creating clip 3 which starts at 00:06:00...
frame= 59 fps=0.0 q=-1.0 Lsize= 31836kB time=00:00:01.97 bitrate=132386.4kbits/s speed=3.06x
Creating clip 4 which starts at 00:08:00...
frame= 60 fps=0.0 q=-1.0 Lsize= 63059kB time=00:00:01.97 bitrate=262223.2kbits/s speed=2.59x
Creating clip 5 which starts at 00:10:00...
frame= 59 fps=0.0 q=-1.0 Lsize= 26968kB time=00:00:01.97 bitrate=112144.4kbits/s speed=2.54x
Creating clip 6 which starts at 00:12:00...
frame= 59 fps=0.0 q=-1.0 Lsize= 34119kB time=00:00:01.97 bitrate=141880.5kbits/s speed= 2.1x
Creating clip 7 which starts at 00:14:00...
frame= 60 fps=0.0 q=-1.0 Lsize= 32754kB time=00:00:01.97 bitrate=136204.1kbits/s speed=2.19x
Creating clip 8 which starts at 00:16:00...
frame= 59 fps= 44 q=-1.0 Lsize= 47558kB time=00:00:01.97 bitrate=197764.6kbits/s speed=1.47x
Creating clip 9 which starts at 00:18:00...
frame= 60 fps= 42 q=-1.0 Lsize= 59101kB time=00:00:01.97 bitrate=245763.1kbits/s speed=1.38x
Creating clip 10 which starts at 00:20:00...
frame= 59 fps= 44 q=-1.0 Lsize= 54827kB time=00:00:01.97 bitrate=227989.8kbits/s speed=1.47x
-----------------------------------------------------------------------------------------------------------
Concatenating the clips to create the overview video...
frame= 594 fps=170 q=-1.0 Lsize= 429257kB time=00:00:19.98 bitrate=175937.3kbits/s speed=5.71x
Done!
The clips have been deleted as they are no longer needed.
Overview Video: 2-120 (ClipLength-IntervalSeconds).mp4
-----------------------------------------------------------------------------------------------------------
CRF comparison mode activated.
CRF values 16, 18, 20, 22, 24 will be compared and the medium preset will be used.
-----------------------------------------------------------------------------------------------------------
Transcoding the video with CRF 16...
frame= 599 fps=9.7 q=-1.0 Lsize= 43880kB time=00:00:19.88 bitrate=18075.7kbits/s dup=5 drop=0 speed=0.322x
Done!
Computing the VMAF...
[LIBVMAF] `compute_vmaf()` is deprecated and will be removed in a future libvmaf version
problem loading model file: vmaf_v0.6.1.pkl
[Parsed_libvmaf_2 @ 0x559896d6fd80] libvmaf encountered an error, check log for details
Error while filtering: Invalid argument
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
Done!
Traceback (most recent call last):
File "main.py", line 368, in <module>
main()
File "main.py", line 204, in main
create_table_plot_metrics(json_file_path, args, decimal_places, data_for_current_row, graph_filename,
File "/home/user/workspace/video-quality-metrics/save_metrics.py", line 12, in create_table_plot_metrics
with open(json_file_path, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '(inputfile.mp4)/CRF comparison at preset medium/Raw JSON Data/CRF 16.json'
Also, in terms of helping to debug this:
Does the vmaf log get written somewhere? I'm not seeing anything by grepping /var/log
for vmaf
(other than my installation of that library) and there's not an obvious verbose mode I could turn on to see what commands it is trying to run, to help with the debugging; perhaps I could add that in a PR.
I added print("Running process: ", " ".join(self.__arguments))
to FfmpegProcess.run()
to see what it was doing, and got:
Running process: ffmpeg -loglevel warning -stats -y -r 30000/1001 -i (input.mp4)/CRF comparison at preset medium/CRF 16.mp4 -r 30000/1001 -i (input.mp4)/2-180 (ClipLength-IntervalSeconds).mp4 -lavfi [0:v]setpts=PTS-STARTPTS[dist];[1:v]setpts=PTS-STARTPTS[ref];[dist][ref]libvmaf=model_path=vmaf_v0.6.1.pkl:phone_model=0:psnr=0:ssim=0:log_path=(input.mp4)/CRF comparison at preset medium/Raw JSON Data/CRF 16.json:log_fmt=json -f null -
[LIBVMAF] `compute_vmaf()` is deprecated and will be removed in a future libvmaf version
problem loading model file: vmaf_v0.6.1.pkl
[Parsed_libvmaf_2 @ 0x55eca0132cc0] libvmaf encountered an error, check log for details
Error while filtering: Invalid argument
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
I'll try using one of the other models that shipped with the vmaf codebase, for more info.
Can you try a pre-built version of ffmpeg to rule out problems with your build?
@georgedorn Since libvmaf v2.0.0, .pkl model files have been deprecated in favour of .json model files. You should no longer run into this issue after pulling the changes that I have made to this repository. Please confirm whether the issue no longer persists after doing so.
It loads the model and gets further now, but the output from the first transcode results in a python error:
CRF comparison mode activated.
CRF values 16, 18, 20, 22, 24 will be compared and the medium preset will be used.
Transcoding the video with CRF 16...
frame= 360 fps= 31 q=-1.0 Lsize= 24699kB time=00:00:11.91 bitrate=16985.8kbits/s dup=3 drop=0 speed=1.02x
Done!
-----------------------------------------------------------------------------------------------------------
Computing the VMAF...
[LIBVMAF] `compute_vmaf()` is deprecated and will be removed in a future libvmaf version
frame= 360 fps=4.7 q=-0.0 Lsize=N/A time=00:00:12.01 bitrate=N/A speed=0.156x
Done!
Traceback (most recent call last):
File "main.py", line 370, in <module>
main()
File "main.py", line 207, in main
create_table_plot_metrics(json_file_path, args, decimal_places, data_for_current_row, graph_filename,
File "/home/gdorn/workspace/video-quality-metrics/save_metrics.py", line 19, in create_table_plot_metrics
mean_vmaf = force_decimal_places(file_contents['pooled_metrics']['vmaf']['mean'], decimal_places)
TypeError: list indices must be integers or slices, not str
Can you compress the JSON file to a zip folder, and attach it to your reply so I can have a look at it? Unfortunately GitHub does not support the attachment of a JSON file.
Looks like the format of the resulting report JSON changed. file_contents['pooled_metrics']
is a list with a single item, a dict, and that item isn't even formatted the way it used to be. I've attached my example here: raw_json.zip
This is interesing. We are both using libvmaf v2.0.0, but with my JSON file, I get something like this under the pooled_metrics
list of dictionaries:
"vmaf": {
"min": 90.471535,
"max": 100.000000,
"mean": 99.733211,
"harmonic_mean": 99.712163
}
hence the file_contents['pooled_metrics']['vmaf']['mean']
works. But you get:
{
"metric": "vmaf",
"pooling_methods": {
"min": 0.000000,
"max": 100.000000,
"mean": 45.482181,
"harmonic_mean": 16.586289
}
}
Here's my JSON file, if you're curious:
CRF 22.zip
Anyway, in the latest commit, I have reverted back to using numpy to get the mean and Python's min
function to get the minimum VMAF, rather than trying to grab the values from the JSON file. This should eliminate your issue. Please report back
Is there any chance we're getting different results due to differences in how we're running the command?
Or a different dependency further down the chain? FWIW I'm on Linux, Xubuntu 20.04, but I had to compile my own ffmpeg and vmaf myself.
In any case, switching back to using numpy seems to have done it, at least as far as the compute_vmaf()
portion is concerned. I'll open a new issue if there's a later problem with reporting.
Thanks, this tool is something I've been wanting for ages!