mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.58k stars 2.92k forks source link

Unable to encode SVT-AV1 or h264_nvenc using MPV #10014

Open OliverMD15 opened 2 years ago

OliverMD15 commented 2 years ago

Important Information

kevinlekiller commented 2 years ago

I'm guessing the ffmpeg's used for building those mpv's didn't enable --enable-libsvtav1?

OliverMD15 commented 2 years ago

Wouldn't disabling --enable-libsvtav1 result in Unknown codec instead of bad parameter (0x80001005) though? Not sure about shinchiro's version, but the version I build myself with media-autobuild_suite did --enable-libsvtav1. Encoding SVT using the FFMPEG version I used for my MPV build worked just fine also, so does FFMPEG from gyan.dev.

kevinlekiller commented 2 years ago

I just tested on my end:

(+) Video --vid=1 (*) (h264 1920x1080 29.970fps)
(+) Audio --aid=1 --alang=eng (*) (truehd 8ch 48000Hz)
[ao/lavc] Opening encoder: libopus Opus [libopus]
AO: [lavc] 48000Hz stereo 2ch float
VO: [lavc] 1920x1080 yuv420p
[vo/lavc] Opening encoder: SVT-AV1(Scalable Video Technology for AV1) encoder [libsvtav1]
Svt[info]: -------------------------------------------
Svt[info]: SVT [version]:       SVT-AV1 Encoder Lib v0.9.0
Svt[info]: SVT [build]  :       GCC 11.2.1 20220103 [revision d4a1d3c4b377f1d4acb34fe1b55b5088a3f293f6]  64 bit
Svt[info]: LIB Build date: Feb 16 2022 00:00:00
Svt[info]: -------------------------------------------
Svt[warn]: TPL off mode is not supported in this release, enable_tpl_la is set to 1
Svt[warn]: EncoderMode (preset): 13 was developed for the sole purpose of debugging and or running fast convex-hull encoding. This configuration should not be used for any benchmarking or quality analysis
Svt[error]: Instance 1: The maximum allowed frame rate is 240 fps
[ffmpeg] libsvtav1: Error setting encoder parameters: bad parameter (0x80001005)
[vo/lavc] Could not initialize encoder.
Could not initialize video chain.
Video: no video
A: -00:00:00 / 00:01:34 (0%) {207.0min 0.0MB}

So looks like the issue is it's trying to set the FPS > 240?

OliverMD15 commented 2 years ago

I thought that was the issue at first too, but forcing a low framerate didn't fix anything for me, so I'm not sure. Maybe it's hard forcing it somehow or something?

OliverMD15 commented 2 years ago

HEVC seems to work fine in MPV, not saying anything about the framerate either, so I dunno.

OliverMD15 commented 2 years ago

Turns out that with mpv-0.33.0-x86_64 NVENC seems to function, even while using the new presets. But the moment I use mpv-0.34.0-x86_64 it all comes crashing down. Not sure if this is related to SVT-AV1, but there ya go. mpv --no-config test.mp4 --ovc=h264_nvenc --ovcopts-add=preset=p7 --vf-add=format=fmt=nv12 --o=mpv_nvenc.mp4

Traneptora commented 2 years ago

Can you try to bisect which commit caused the issue exactly?

OliverMD15 commented 2 years ago

mpv-x86_64-20210214-git-93066ff (2021-02-14) Here it still works mpv-x86_64-20210228-git-d1be8bb 2021-02-28} From here on out it's broken. Hope this is what you wanted, and that it helps.

Traneptora commented 2 years ago

I think this might be an issue of B-frames, a la FFmpeg/FFmpeg@a0949d0bcb0eee2f3fffcf9a4810c0295d14c0dc. See if setting --ovcopts-add=bf=0 helps.

OliverMD15 commented 2 years ago

To my surprise, it does indeed help (fix) it. How come that turning off b-frames of all things fixes it though? Not sure on how impactful completely turning off bf is, but at the very least it's a workaround for the time being. Now I wonder if SVT-AV1 is as easy to fix like this too, though I've some doubts.

imkunet commented 1 year ago

Hello! I'm also experiencing the same troubles with mpv with libsvtav1, has anyone found a solution?