feat: encodage vidéo libsvtav1 avec HDR10 statique et HDR10+ via svtav1-params
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -182,17 +182,13 @@ def convert_audio(file, track, volume_adj, channels, channel_layout, language, t
|
|||||||
logging.error(result)
|
logging.error(result)
|
||||||
|
|
||||||
|
|
||||||
def convert_video(file, infos, start, crop, crf, animation, interlaced, vhs):
|
def convert_video(file, infos, crf, crop, enc_options, interlaced, vhs):
|
||||||
str_start = "{:05d}".format(start)
|
output = f'{file}_video.mkv'
|
||||||
output = f'{file}_video_t{str_start}.mkv'
|
|
||||||
fmt = "yuv420p10le"
|
fmt = "yuv420p10le"
|
||||||
track = infos['video']['index']
|
track = infos['video']['index']
|
||||||
codec = 'libx265 -preset slower'
|
codec = 'libsvtav1'
|
||||||
|
svtav1_params = enc_options
|
||||||
hdr = ''
|
hdr = ''
|
||||||
if animation:
|
|
||||||
tune = "-tune animation"
|
|
||||||
else:
|
|
||||||
tune = ""
|
|
||||||
if interlaced:
|
if interlaced:
|
||||||
crop = f"{crop},yadif"
|
crop = f"{crop},yadif"
|
||||||
if vhs:
|
if vhs:
|
||||||
@@ -229,10 +225,22 @@ def convert_video(file, infos, start, crop, crf, animation, interlaced, vhs):
|
|||||||
max_luminance = int(int(max_luminance[0])*(int(max_luminance[1])/10000))
|
max_luminance = int(int(max_luminance[0])*(int(max_luminance[1])/10000))
|
||||||
luminance = f'L\({max_luminance},{min_luminance}\)'
|
luminance = f'L\({max_luminance},{min_luminance}\)'
|
||||||
master_display = green + blue + red + white_point + luminance
|
master_display = green + blue + red + white_point + luminance
|
||||||
hdr = f'-x265-params hdr-opt=1:repeat-headers=1:colorprim={color_primaries}:transfer={color_transfer}:colormatrix={color_space}:master-display={master_display}:max-cll={light_level}'
|
hdr = f'mastering-display={master_display}:content-light={light_level}'
|
||||||
|
if svtav1_params:
|
||||||
|
svtav1_params = f'{svtav1_params}:{hdr}'
|
||||||
|
else:
|
||||||
|
svtav1_params = hdr
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logging.debug(f"Aucune information HDR : {err}")
|
logging.debug(f"Aucune information HDR statique : {err}")
|
||||||
command = f'ffmpeg -loglevel error -i {file} -map 0:{track} -ss {start} -t 300 -an -sn -c:v {codec} {tune} {hdr} -crf {crf} -pix_fmt {fmt} -filter:v {crop} -y {output}'
|
if 'hdr10plus' in infos['video']:
|
||||||
|
hdr10plus_param = f"hdr10plus-json={infos['video']['hdr10plus_metadata']}"
|
||||||
|
if svtav1_params:
|
||||||
|
svtav1_params = f'{svtav1_params}:{hdr10plus_param}'
|
||||||
|
else:
|
||||||
|
svtav1_params = hdr10plus_param
|
||||||
|
svtav1_args = f'-svtav1-params {svtav1_params}' if svtav1_params else ''
|
||||||
|
command = f'ffmpeg -loglevel error -i {file} -map 0:{track} -an -sn -c:v {codec} {svtav1_args} -crf {crf} -pix_fmt {fmt} -filter:v {crop} -y {output}'
|
||||||
|
logging.info("Encodage vidéo en cours (AV1-SVT)...")
|
||||||
logging.debug(command)
|
logging.debug(command)
|
||||||
result = subprocess.getoutput(command)
|
result = subprocess.getoutput(command)
|
||||||
if result != "":
|
if result != "":
|
||||||
|
|||||||
Reference in New Issue
Block a user