Compare commits
2 Commits
184c75e8e7
...
2479ee4b96
Author | SHA1 | Date | |
---|---|---|---|
2479ee4b96 | |||
7634ad4fad |
@ -6,6 +6,7 @@ import subprocess
|
||||
import logging
|
||||
from os import listdir, remove
|
||||
|
||||
|
||||
def get_infos(file):
|
||||
'''
|
||||
Cette fonction extrait les informations du film à l'aide de ffprobe et les stocke
|
||||
@ -53,7 +54,7 @@ def get_infos(file):
|
||||
}
|
||||
try:
|
||||
a_stream_infos.update({'title': a_stream['tags']['title']})
|
||||
except:
|
||||
except KeyError:
|
||||
a_stream_infos.update({'title': 'No title'})
|
||||
a_infos.append(a_stream_infos)
|
||||
s_infos = []
|
||||
@ -69,7 +70,9 @@ def get_infos(file):
|
||||
hdr10_v_raw = subprocess.getoutput(hdr10_v_cmd)
|
||||
if 'metadata detected' in hdr10_v_raw:
|
||||
hdr10_cmd = f'ffmpeg -loglevel panic -i {file} -c:v copy -vbsf hevc_mp4toannexb -f hevc - | hdr10plus_parser -o /tmp/{file}_hdr10_metadata.json -'
|
||||
v_infos.update({'hdr10': True, 'hdr10_metdata': f'/tmp/{file}_hdr10_metadata.json'})
|
||||
hdr10_cmd_res = subprocess.getoutput(hdr10_cmd)
|
||||
logging.debug(hdr10_cmd_res)
|
||||
v_infos.update({'hdr10plus': True, 'hdr10plus_metadata': f'/tmp/{file}_hdr10_metadata.json'})
|
||||
infos = {'duration': duration, 'video': v_infos, 'audio': a_infos, 'subtitles': s_infos}
|
||||
logging.debug("Informations du film : \n" + json.dumps(infos, indent=True))
|
||||
return infos
|
||||
@ -153,7 +156,6 @@ def extract_subs(file, track, lang):
|
||||
|
||||
|
||||
def convert_audio(file, track, volume_adj, channels, channel_layout, language, title):
|
||||
bitrate = f'{64*channels}k'
|
||||
if channel_layout == "5.1(side)":
|
||||
channel_layout = "5.1"
|
||||
codec = 'libfdk_aac -vbr 5'
|
||||
@ -167,7 +169,7 @@ def convert_audio(file, track, volume_adj, channels, channel_layout, language, t
|
||||
def convert_video(file, infos, start, crop, crf, animation):
|
||||
str_start = "{:05d}".format(start)
|
||||
output = f'{file}_video_t{str_start}.mkv'
|
||||
fmt = "yuv420p10le" # Always 10-bits
|
||||
fmt = "yuv420p10le"
|
||||
track = infos['video']['index']
|
||||
codec = 'libx265 -preset slower'
|
||||
hdr = ''
|
||||
@ -208,8 +210,8 @@ def convert_video(file, infos, start, crop, crf, animation):
|
||||
luminance = f'L\({max_luminance},{min_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}'
|
||||
except:
|
||||
logging.debug("Aucune information HDR")
|
||||
except Exception as err:
|
||||
logging.debug(f"Aucune information HDR : {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}'
|
||||
logging.debug(command)
|
||||
result = subprocess.getoutput(command)
|
||||
@ -225,7 +227,7 @@ def create_mkv(filename):
|
||||
json_data.append("--no-track-tags")
|
||||
json_data.append("--no-global-tags")
|
||||
json_data.append("--no-chapters")
|
||||
if not "t00000" in file:
|
||||
if "t00000" not in file:
|
||||
json_data.append("+")
|
||||
json_data.append("(")
|
||||
json_data.append(file)
|
||||
|
Loading…
Reference in New Issue
Block a user