xiph / rav1e

The fastest and safest AV1 encoder.
BSD 2-Clause "Simplified" License
3.71k stars 253 forks source link

Is there a way to selectively disable some or all of those intra-antinoise filters? #2675

Open Joachim-Otahal opened 3 years ago

Joachim-Otahal commented 3 years ago

From the first 0.3.0/0.3.1/0.3.2 builds I've tried and now the latest 0.5.0 one thing is bugging me: There must be filters which kill way too much detail. Even in regions which are not noisy, and which are simple contrasts (like Anime / Simpsons style animation). The result is either that even a nearly horizontal dark line gets visibly blurred, or other structures are visibly blurred. Comparing to SVT and x265, where I do have options to disable some of those detail-killers, I have no chance with rav1e. The only way I am able to somewhat match x265 (with no-sao, no-strong-intra and crf 21.5) is using insanely high settings (q50 s2 with 2x2 tiles for example) which end up in file sizes larger than the x265 encoding I compare against. If there are undocumented command line switches which can help please tell, else rav1e is still useless for me. Here a short 30s snippet for you to test (Source: DVBS/MPEG2 720x576 25 fps, just remuxed to .mkv). https://joumxyzptlk.de/tmp/Alpha_Centauri_1998_Asteroiden_-_Bomben_aus_dem_All_ARD-alpha_20190107_0205.mkv

Joachim-Otahal commented 3 years ago

PS: Command line is: c:\prog\ffmpeg\bin\ffmpeg.exe -hide_banner -loglevel quiet -i "%input%" -pix_fmt yuv420p -f yuv4mpegpipe - | "C:\prog\rav1e\rav1e.exe" - %s% %q% %tc% %tr% --output "%output%.ivf" Where those environment variables are filled with the quantizer(aka quality)/speed/tiles settings mentioned above.

Joachim-Otahal commented 3 years ago

PPS: x265 preset is "slow"

negge commented 3 years ago

Thanks for reporting this @JouMxyzptlk.

Would it be possible for you to come on our IRC channel to discuss further? We are on #daala on freenode.

Joachim-Otahal commented 3 years ago

Command lines:

c:\prog\ffmpeg\bin\ffmpeg.exe  -hide_banner -loglevel error -stats -n -i "X:\tmp\video-in\noencode(SD)\Alpha Centauri 1998 Asteroiden 30s.mkv"  -max_muxing_queue_size 1024 -vsync 0 -map 0:v:0? -map 0:a? -map 0:s? -map 0:t? -c copy -map_metadata 0  -acodec aac -b:a 128k -c:v libx265 -preset slow  -crf 21.5 -x265-params log-level=error:strong-intra-smoothing=0:no-sao=1 "X:\tmp\video-in\noencode(SD)\Alpha Centauri 1998 Asteroiden 30s.x265.crf21.5.aac128.mkv"
c:\prog\ffmpeg\bin\ffmpeg.exe -hide_banner -loglevel quiet -i "X:\tmp\video-in\noencode(SD)\Alpha Centauri 1998 Asteroiden 30s.mkv" -an  -pix_fmt yuv420p -f yuv4mpegpipe -   | c:\prog\svt-av1\SvtAv1EncApp.exe --input stdin --frames 99999999 --rc 0 -q 28  --preset 3  --tf-level 0 --altref-strength 0 --altref-nframes 0 --filter-intra-level 0 --enable-intra-edge-filter 0 --output "X:\tmp\video-in\noencode(SD)\Alpha Centauri 1998 Asteroiden 30s.svt086.p4.q28.noaltrefs.aac128.ars0.arf0.ivf"
c:\prog\ffmpeg\bin\ffmpeg.exe -hide_banner -loglevel quiet -i "X:\tmp\video-in\noencode(SD)\Alpha Centauri 1998 Asteroiden 30s.mkv"  -an  -pix_fmt yuv420p -f yuv4mpegpipe -   | "C:\prog\rav1e\rav1e.exe" - --speed 2 --quantizer 75 --tile-cols 4 --tile-rows 4  --output "X:\tmp\video-in\noencode(SD)\Alpha Centauri 1998 Asteroiden 30s.rav1e050.q75.s2.tc4.tr4.aac128.ivf"
Joachim-Otahal commented 3 years ago

Original DVB-S Original DVB-S

x265 crf21.5 preset-slow no-sao no-strong-intra x265 crf21.5 preset-slow

rav1e 0.5.0 q65 s2 tc2 tr2 rav1e050 q65 s2 tc2 tr2

rav1e 0.5.0 q35 s2 tc2 tr2 result-is-larger-than-x265 rav1e050 q35 s2 tc2 tr2 result-is-larger-than-x265

BlueSwordM commented 3 years ago

I've noticed just now, but I'd be careful about using the --tile-rows and --tile-columns parameters and instead use --tiles instead.

With the current setup you have, you are using 4² tile columns * 4² tile rows, which is equal to 256 tiles, since the parameter is based on the power of 2. --tiles does not have that issue. It doesn't matter too much in the end, as a 1080p stream has a maximum tile number of 32.

In the meantime, could you give me the end file sizes for each created stream? I'd be interested in testing it out myself.

Joachim-Otahal commented 3 years ago

I've noticed just now, but I'd be careful about using the --tile-rows and --tile-columns parameters and instead use --tiles instead. With the current setup you have, you are using 4² tile columns * 4² tile rows, which is equal to 256 tiles, since the parameter is based on the power of 2. --tiles does not have that issue.

As far as I know this applies to SVT-AV1, taking the given tile value and ² it. As far as rav1e is concerned, and as the help suggests, it does not apply to rav1e.

The console confirms me:

c:\prog\ffmpeg\bin\ffmpeg.exe -hide_banner -loglevel quiet -i "X:\tmp\video-in\noencode(SD)\Alpha Centauri 1998 Asteroiden 30s.mkv"  -an  -pix_fmt yuv420p -f yuv4mpegpipe -   | "C:\prog\rav1e\rav1e.exe" - --speed 3 --quantizer 85 --tile-cols 4 --tile-rows 4 --tune psnr --output "X:\tmp\video-in\noencode(SD)\Alpha Centauri 1998 Asteroiden 30s.rav1e050.q85.s3.tc4.tr4.aac128.psnr.ivf"
>  Using y4m decoder: 720x576p @ 25/1 fps, 4:2:0, 8-bit
>  Encoding settings: keyint_min=12 keyint_max=240 quantizer=85 bitrate=0 min_quantizer=0 low_latency=false tune=Psnr rdo_lookahead_frames=40 min_block_size=8x8 max_block_size=64x64 multiref=true fast_deblock=false reduced_tx_set=false tx_domain_distortion=true tx_domain_rate=false encode_bottomup=false rdo_tx_decision=true prediction_modes=Complex-KFs include_near_mvs=true no_scene_detection=false cdef=true use_satd_subpel=true non_square_partition=false enable_timing_info=false fine_directional_intra=true
>  CPU Feature Level: AVX2
>  Using 12 tiles (4x3)
Joachim-Otahal commented 3 years ago

In the meantime, could you give me the end file sizes for each created stream? I'd be interested in testing it out myself.

Instead of the size I give you the encoded streams as well. They are all muxed with aac128 audio after encoding to keep it comparable with my x265 variant.

Complete example command line and output for q85 s3 tc2 tr2, all other only change the q value:

X:\tmp>c:\prog\ffmpeg\bin\ffmpeg.exe -hide_banner -loglevel quiet -i "X:\tmp\Alpha Centauri 1998 Asteroiden 30s.mkv"  -an  -pix_fmt yuv420p -f yuv4mpegpipe -   | "C:\prog\rav1e\rav1e.exe" - --speed 3 --quantizer 85 --tile-cols 2 --tile-rows 2  --output "X:\tmp\Alpha Centauri 1998 Asteroiden 30s.rav1e050.q85.s3.tc2.tr2.aac128.ivf"
>  Using y4m decoder: 720x576p @ 25/1 fps, 4:2:0, 8-bit
>  Encoding settings: keyint_min=12 keyint_max=240 quantizer=85 bitrate=0 min_quantizer=0 low_latency=false tune=Psychovisual rdo_lookahead_frames=40 min_block_size=8x8 max_block_size=64x64 multiref=true fast_deblock=false reduced_tx_set=false tx_domain_distortion=false tx_domain_rate=false encode_bottomup=false rdo_tx_decision=true prediction_modes=Complex-KFs include_near_mvs=true no_scene_detection=false cdef=true use_satd_subpel=true non_square_partition=false enable_timing_info=false fine_directional_intra=true
>  CPU Feature Level: AVX2
>  Using 4 tiles (2x2)
>  encoded 757 frames, 5.807 fps, 709.81 Kb/s, elap. time: 2m 10s
>  ----------
>  Key frame:             4 | avg QP:  63.00 | avg size:   34995 B
>  Inter frame:         753 | avg QP: 125.00 | avg size:    3381 B
>  Intra only frame:      0 | avg QP:   0.00 | avg size:       0 B
>  Switching frame:       0 | avg QP:   0.00 | avg size:       0 B
>  ----

X:\tmp>c:\prog\ffmpeg\bin\ffmpeg.exe -hide_banner -loglevel error -n -i "X:\tmp\Alpha Centauri 1998 Asteroiden 30s.mkv"  -i "X:\tmp\Alpha Centauri 1998 Asteroiden 30s.rav1e050.q85.s3.tc2.tr2.aac128.ivf" -map 1:v:0 -map 0:a:0? -map 0:s:0? -map 0:t:0? -c copy -acodec aac -b:a 128k "X:\tmp\Alpha Centauri 1998 Asteroiden 30s.rav1e050.q85.s3.tc2.tr2.aac128.mkv"

The sizes (first one is the DVB-S original):

2021-02-21  19:43        16.223.935 Alpha Centauri 1998 Asteroiden 30s.mkv
2021-02-24  22:41        14.830.004 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q25.s3.tc2.tr2.aac128.mkv
2021-02-24  22:41        12.606.659 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q30.s3.tc2.tr2.aac128.mkv
2021-02-24  22:40        10.787.842 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q35.s3.tc2.tr2.aac128.mkv
2021-02-24  22:40         9.355.539 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q40.s3.tc2.tr2.aac128.mkv
2021-02-24  22:40         8.128.817 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q45.s3.tc2.tr2.aac128.mkv
2021-02-24  22:39         7.096.041 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q50.s3.tc2.tr2.aac128.mkv
2021-02-24  22:36         6.204.080 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q55.s3.tc2.tr2.aac128.mkv
2021-02-24  22:36         5.462.559 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q60.s3.tc2.tr2.aac128.mkv
2021-02-24  22:36         4.807.211 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q65.s3.tc2.tr2.aac128.mkv
2021-02-24  22:35         4.294.027 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q70.s3.tc2.tr2.aac128.mkv
2021-02-24  22:35         3.882.173 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q75.s3.tc2.tr2.aac128.mkv
2021-02-24  22:35         3.505.059 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q80.s3.tc2.tr2.aac128.mkv
2021-02-24  22:35         3.184.389 Alpha Centauri 1998 Asteroiden 30s.rav1e050.q85.s3.tc2.tr2.aac128.mkv
2021-02-21  19:43         5.168.948 Alpha Centauri 1998 Asteroiden 30s.x265.crf21.5.aac128.mkv

From those I consider Q35 to make the sweater right, as good as x265. But his forehead wrinkle are sill mashed out... I could live with it if the file size would be smaller.

all files: https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q25.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q30.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q35.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q40.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q45.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q50.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q55.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q60.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q65.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q70.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q75.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q80.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.rav1e050.q85.s3.tc2.tr2.aac128.mkv https://joumxyzptlk.de/tmp/rav1e050/Alpha%20Centauri%201998%20Asteroiden%2030s.x265.crf21.5.aac128.mkv

Happy testing! If you want an anime-snippet exposing it say so. Though that sample would be 1080p and take more of your time to reproduce.