kingstefan26 / alabamaEncoder

AlabamaEncoder is a video encoder framework, with a focus on chunked target quality encoding
MIT License
7 stars 1 forks source link

Possible VMAF calculation issue #6

Open Extarys opened 1 week ago

Extarys commented 1 week ago

I activated print_analysis_logs because I was curious to see more stats :D, but I noticed something strange. When the CRF changes, the vmaf score and bitrate doesn't reflect the new CRF.

I don't see any lines with more than 3 attempts., so it might be only a logging issue though (like variables not being set right or something).

I rearrange the log by chuck so it's easier to see:

[70] crf: 28; vmaf: 96.187366; score_error: 3.2021752709565963; bitrate: 2377 kb/s; attempt 0/10                                                                                                
[70] crf: 37; vmaf: 96.187366; score_error: 3.2021752709565963; bitrate: 2377 kb/s; attempt 1/10                                                                                                
[70] crf: 42; vmaf: 96.187366; score_error: 3.2021752709565963; bitrate: 2377 kb/s; attempt 2/10     
[...]                                                                                           
[70] Finished with crf 45; vmaf: 96.187366; score_error: 3.2021752709565963; bitrate: 2377 kb/s                                                                                                 

[72] crf: 28; vmaf: 94.768922; score_error: 0.9940820884372329; bitrate: 1415 kb/s; attempt 0/10          
[72] crf: 37; vmaf: 94.768922; score_error: 0.9940820884372329; bitrate: 1415 kb/s; attempt 1/10                                                                                                
[72] crf: 42; vmaf: 94.768922; score_error: 0.9940820884372329; bitrate: 1415 kb/s; attempt 2/10                                                                                                
[72] crf: 45; vmaf: 94.768922; score_error: 0.9940820884372329; bitrate: 1415 kb/s; attempt 3/10
[72] Finished with crf 45; vmaf: 94.768922; score_error: 0.9940820884372329; bitrate: 1415 kb/s                                                                    

[73] crf: 28; vmaf: 95.864913; score_error: 2.2315003263536246; bitrate: 1961 kb/s; attempt 0/10        
[73] crf: 37; vmaf: 95.864913; score_error: 2.2315003263536246; bitrate: 1961 kb/s; attempt 1/10                                                                                                
[73] crf: 42; vmaf: 95.864913; score_error: 2.2315003263536246; bitrate: 1961 kb/s; attempt 2/10      
[...]
[73] Finished with crf 45; vmaf: 95.864913; score_error: 2.2315003263536246; bitrate: 1961 kb/s                                                                                                 

EDIT All chunks are tried three times and it always settles to CRF 45, I've set the ("undocumented") --crf_limits 15,50 EDIT 2 Same symptoms without crf_limits

kingstefan26 commented 6 days ago

this is usually symptomatic of all black scenes, is it happening to all scenes? could you please check what is contained in the affected scenes?

Extarys commented 6 days ago

I didn't think of that, but testing now, I have similar logs today and the chunk number doesn't match a blank screen. I'll let the encode run for 10 minutes to make sure all chunks are encoded with vmaf 33

[2] crf: 26; vmaf: 97.295752; score_error: 2.295751999999993; bitrate: 534 kb/s; attempt 0/10                                                                                                   
[2] crf: 29; vmaf: 97.295752; score_error: 2.295751999999993; bitrate: 534 kb/s; attempt 1/10   
[2] crf: 32; vmaf: 97.295752; score_error: 2.295751999999993; bitrate: 534 kb/s; attempt 2/10      
[2] crf: 33; vmaf: 97.295752; score_error: 2.295751999999993; bitrate: 534 kb/s; attempt 3/10                                                                                                   
[2] Finished with crf 33; vmaf: 97.295752; score_error: 2.295751999999993; bitrate: 534 kb/s        

[8] crf: 26; vmaf: 93.289506; score_error: 3.030078215111861; bitrate: 2307 kb/s; attempt 0/10                                                                                                  
[8] crf: 29; vmaf: 93.289506; score_error: 3.030078215111861; bitrate: 2307 kb/s; attempt 1/10                                                                                                  
[8] crf: 32; vmaf: 93.289506; score_error: 3.030078215111861; bitrate: 2307 kb/s; attempt 2/10                                                                                                  
[8] crf: 33; vmaf: 93.289506; score_error: 3.030078215111861; bitrate: 2307 kb/s; attempt 3/10                                                                                                  
[8] Finished with crf 33; vmaf: 93.289506; score_error: 3.030078215111861; bitrate: 2307 kb/s                                                                                                   

[21] crf: 29; vmaf: 91.035632; score_error: 4.751382064575417; bitrate: 1490 kb/s; attempt 1/10                                                                                                 
[23] crf: 26; vmaf: 94.251939; score_error: 1.8466526287236351; bitrate: 1942 kb/s; attempt 0/10                                                                                                
[23] crf: 29; vmaf: 94.251939; score_error: 1.8466526287236351; bitrate: 1942 kb/s; attempt 1/10                                                                                                
[23] crf: 32; vmaf: 94.251939; score_error: 1.8466526287236351; bitrate: 1942 kb/s; attempt 2/10                                                                                                
[23] crf: 33; vmaf: 94.251939; score_error: 1.8466526287236351; bitrate: 1942 kb/s; attempt 3/10                                                                                                
[23] Finished with crf 33; vmaf: 94.251939; score_error: 1.8466526287236351; bitrate: 1942 kb/s    

Chunk 2 is a disclaimer like "based on true story" Chunk 8 is at night outside Chunk 23 is a fast moving scene

alabamaEncoder encode "..." "./....webm" --title "..." --vmaf_target 95 --dynamic_vmaf_target --chunk_order even -previews -stats --tune balanced --grain 8 --bitrate_adjust_mode global \
--video_filters "unsharp=7:7:0.8:7:7:0.8" --encoder_speed_override 4 --encoder_flag_override "--enable-dlf 2 --film-grain-denoise 0" --print_analysis_logs

Test 2: I've found the culprit. If I remove --enable-dlf 2 from encoder_flag_override and the sharppening filter, the VMAF score changes now depending on the CRF value. So not an alabamaEncoder issue 🎉

Please close this issue at your own discretion. :hugs:

EDIT:

My source is a bit blurry. Any way to sharpen it a bit without breaking VMAF target quality ?

I've tried a weaker filter: --video_filters "unsharp=7:7:0.8:7:7:0.8" and a stronger one: --video_filters "unsharp=11:11:1.0:11:11:1.0" and the encoder always pick CRF 33, the VMAF score stays the same no matter what the CRF is.

Extarys commented 5 days ago

Ohhh my bad, --dynamic_vmaf_target causes this behaviour.

Now I believe there is an issue in how alabamaEncoder treat this flag.