Default poor libvpx quality (master branch)
apiraino opened this issue · comments
So, now wf-recorder defaults to the VP8 encoder instead of h264.
I'm running wf-recorder compiled from 460d454 and I observe that the defaults for the libvpx codec produce a low quality ("blockier") video while defaults for h264 produced a better video, example:
wf-recorder -a --log
The low quality of the video is also explained by this warning
[libvpx @ 0x7fbd240022c0] Neither bitrate nor constrained quality specified, using default CRF of 32 and bitrate of 256kbit/sec
As per this issue, I tried to tweak the quality with this command but unfortunately the previous warning persists:
wf-recorder -a -pqmin=0 -pqmax={tried from 32 to 50} --log
How can this codec be configured for better quality?
cc @Conan-Kudo that authored #198 and hopefully more knowledgeable. Can you please share a configuration for the new default codec that results in a good video quality?
thanks
As an alternative, you can always choose another codec with -c (vp9, libx264 are probably better alternatives if your ffmpeg and video players support them, which is usually the case)
@ammen99 thanks for the tip. The thing is that tweaking VP8 or VP9 is tricky, I'm trying to force wf-recorder to use the parameters I pass from the command line, no luck for now. Examples:
# error
wf-recorder -a -c libvpx-vp9 -pminrate=500K -pmaxrate=500K -pb:v=500K
# params ignored?
wf-recorder -a -c libvpx-vp9 -pcrf=30 -pb:v=0
# params ignored?
wf-recorder -a -c libvpx-vp9 -pcrf=30 -pb:v=2000K
In addition VP9 needs some additional params (-pdeadline=realtime -pspeed=8
) to reduce the lag when the encoder is crunching frames (also mentioned in #80 and here).
I should probably also mention that previously wf-recorder (using the default h264 codec) produced the following file:
$ wf-recorder -a -c libx264
...
Setting codec option: crf=20
Setting codec option: preset=ultrafast
Setting codec option: tune=zerolatency
# Bitrate video
Bit rate : 49.4 Gb/s
Maximum bit rate : 2 424 kb/s
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
which was absolutely adequate. These are the values I'm more or less aiming for.
What KPipeWire does is set threads=4
, preset=ultrafast
, tune-content=screen
, deadline=good
. That's probably a good way to go.
ok, after some more tests here's a good version of wf-recorder using VP9:
wf-recorder \
# use the VP9 codec
-c libvpx-vp9 \
# fastest encoding possible
-p deadline=realtime -p speed=8 -p threads=4 \
# tune the video quality
-p preset=ultrafast -p tune-content=screen
Worth noticing that the combination of VP9 codec + audio with Opus does not work. Example, adding the following to the previous command:
-a alsa_input.pci-0000_00_1f.3.analog-stereo --audio-codec=libopus \
no idea why, with libvorbis it works. I guess it's something on ffmpeg? 🤷♂️
Thanks everyone for the suggestions.
Do we want to try to update the wf-recorder defaults for this?
Do we want to try to update the wf-recorder defaults for this?
If it improves the quality with default settings, it makes sense, yes.