Compare commits
No commits in common. "2479ee4b96d0a6733f4266d77c3135f8781e873b" and "184c75e8e723e897c509bfa63d107a620051f92b" have entirely different histories.
2479ee4b96
...
184c75e8e7
@ -6,7 +6,6 @@ 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
|
||||
@ -54,7 +53,7 @@ def get_infos(file):
|
||||
}
|
||||
try:
|
||||
a_stream_infos.update({'title': a_stream['tags']['title']})
|
||||
except KeyError:
|
||||
except:
|
||||
a_stream_infos.update({'title': 'No title'})
|
||||
a_infos.append(a_stream_infos)
|
||||
s_infos = []
|
||||
@ -70,9 +69,7 @@ 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 -'
|
||||
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'})
|
||||
v_infos.update({'hdr10': True, 'hdr10_metdata': 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
|
||||
@ -156,6 +153,7 @@ 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'
|
||||
@ -169,7 +167,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"
|
||||
fmt = "yuv420p10le" # Always 10-bits
|
||||
track = infos['video']['index']
|
||||
codec = 'libx265 -preset slower'
|
||||
hdr = ''
|
||||
@ -210,8 +208,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 Exception as err:
|
||||
logging.debug(f"Aucune information HDR : {err}")
|
||||
except:
|
||||
logging.debug("Aucune information HDR")
|
||||
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)
|
||||
@ -227,7 +225,7 @@ def create_mkv(filename):
|
||||
json_data.append("--no-track-tags")
|
||||
json_data.append("--no-global-tags")
|
||||
json_data.append("--no-chapters")
|
||||
if "t00000" not in file:
|
||||
if not "t00000" in file:
|
||||
json_data.append("+")
|
||||
json_data.append("(")
|
||||
json_data.append(file)
|
||||
|
Loading…
Reference in New Issue
Block a user