feat: ajout find_crf via ab-av1 crf-search (VMAF 96)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import json
|
|||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
import logging
|
||||||
from os import listdir, remove
|
from os import listdir, remove
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
def get_infos(file):
|
def get_infos(file):
|
||||||
@@ -116,6 +117,35 @@ def volume_audio(file, infos):
|
|||||||
return volumes
|
return volumes
|
||||||
|
|
||||||
|
|
||||||
|
VMAF_HDR_MODEL = '/usr/share/vmaf/model/vmaf_4k_v0.6.1.json'
|
||||||
|
|
||||||
|
def find_crf(file, enc_options, hdr=False):
|
||||||
|
'''
|
||||||
|
Détermine le CRF optimal via ab-av1 crf-search pour atteindre VMAF 96.
|
||||||
|
Pour les sources HDR, utilise un modèle VMAF calibré 4K HDR si disponible.
|
||||||
|
'''
|
||||||
|
logging.info("Recherche du CRF optimal (VMAF 96)...")
|
||||||
|
vmaf_model = ''
|
||||||
|
if hdr and os.path.exists(VMAF_HDR_MODEL):
|
||||||
|
vmaf_model = f'--vmaf-model path={VMAF_HDR_MODEL}'
|
||||||
|
logging.debug(f"Modèle VMAF HDR utilisé : {VMAF_HDR_MODEL}")
|
||||||
|
cmd = f'ab-av1 crf-search --input {file} --encoder libsvtav1 --vmaf 96 {vmaf_model} --enc {enc_options}'
|
||||||
|
logging.debug(cmd)
|
||||||
|
result = subprocess.getoutput(cmd)
|
||||||
|
logging.debug(result)
|
||||||
|
for line in result.splitlines():
|
||||||
|
# ab-av1 émet une ligne du type : "crf 32 VMAF 96.21 ..."
|
||||||
|
if 'crf' in line and 'VMAF' in line:
|
||||||
|
try:
|
||||||
|
crf = int(line.split('crf')[1].split()[0])
|
||||||
|
logging.info(f"CRF optimal trouvé : {crf}")
|
||||||
|
return crf
|
||||||
|
except (IndexError, ValueError):
|
||||||
|
pass
|
||||||
|
logging.warning("ab-av1 crf-search a échoué, utilisation du CRF par défaut (32)")
|
||||||
|
return 32
|
||||||
|
|
||||||
|
|
||||||
def stabilization(file):
|
def stabilization(file):
|
||||||
'''
|
'''
|
||||||
Cette fonction permet de stabiliser l'image,
|
Cette fonction permet de stabiliser l'image,
|
||||||
|
|||||||
Reference in New Issue
Block a user