Commit 77402b2a by xiaoqi

脚本

parent 7e72e89e
Showing with 49 additions and 35 deletions
......@@ -39,22 +39,6 @@ def find_files_by_prefixes(directory, prefixes):
# 返回所有匹配的文件路径
return matching_files
# p_codec = "libx264"
# p_bitrate = "2000k"
# p_fps = 0
# p_enable_sharpening = "" # 5:5: 1.5:0: 0:0 //
# """
# luma_msize_x:亮度矩阵的水平大小(X方向)。这个值定义了应用于亮度分量的模糊矩阵的宽度。
# luma_msize_y:亮度矩阵的垂直大小(Y方向)。这个值定义了应用于亮度分量的模糊矩阵的高度。
# luma_amount:亮度锐化强度。正值表示锐化,负值表示模糊。通常范围从 -2.0 到 5.0。
# chroma_msize_x:色度矩阵的水平大小(X方向)。与亮度类似,但应用于色度分量。
# chroma_msize_y:色度矩阵的垂直大小(Y方向)。
# chroma_amount:色度锐化强度。
# """
# p_enable_denoising = "" # 4:3:6:4 亮度空间去噪强度 亮度时间去噪强度 色度空间去噪强度 色度时间去噪强度
# p_enable_color_enhancement = ""#色彩增强
# sys.argv 是一个列表,第一个元素是脚本名,后续是传递的参数
def is_null_or_empty(s):
return s is None or s == ""
......@@ -63,11 +47,11 @@ script_name = sys.argv[0] # 脚本名
gift_id = sys.argv[1] # 第一个参数
motoring_id = sys.argv[2] # 第一个参数
crf = sys.argv[3] # 第一个参数
p_fps = sys.argv[4] # 第一个参数
p_bitrate = sys.argv[5] # 第一个参数
p_enable_sharpening = sys.argv[6] # 第一个参数
p_enable_denoising = sys.argv[7] # 第一个参数
p_enable_color_enhancement = sys.argv[8] # 第一个参数
fps = sys.argv[4] # 第一个参数
bitrate = sys.argv[5] # 第一个参数
sharpening = sys.argv[6] # 第一个参数
denoising = sys.argv[7] # 第一个参数
color_enhancement = sys.argv[8] # 第一个参数
webp_path_or_dir = sys.argv[9] # 第一个参数
# if not is_null_or_empty(gift_id):
# webp_path_or_dir = find_first_file("webp_dir", gift_id)
......@@ -75,27 +59,57 @@ webp_path_or_dir = sys.argv[9] # 第一个参数
# if not is_null_or_empty(motoring_id):
# webp_path_or_dir = find_first_file("motoring", motoring_id)
convert_webp_2_mp4.p_crf = crf
if not is_null_or_empty(p_fps):
convert_webp_2_mp4.p_fps = int(p_fps)
convert_webp_2_mp4.p_enable_sharpening = p_enable_sharpening
convert_webp_2_mp4.p_bitrate = p_bitrate
convert_webp_2_mp4.p_enable_denoising = p_enable_denoising
convert_webp_2_mp4.p_enable_color_enhancement = p_enable_color_enhancement
if not is_null_or_empty(fps):
convert_webp_2_mp4.p_fps = int(fps)
convert_webp_2_mp4.p_enable_sharpening = sharpening
convert_webp_2_mp4.p_bitrate = bitrate
convert_webp_2_mp4.p_enable_denoising = denoising
convert_webp_2_mp4.p_enable_color_enhancement = color_enhancement
# convert_webp_2_mp4.check_file_or_dir(webp_path_or_dir)
# print(f"shurude={crf} dir={webp_path_or_dir}")
print(f"入参:gift_id={gift_id}")
print(f"入参:motoring_id={motoring_id}")
print(f"入参:crf={crf}")
print(f"入参:p_fps={p_fps}")
print(f"入参:p_bitrate={p_bitrate}")
print(f"入参:p_enable_sharpening={p_enable_sharpening}")
print(f"入参:p_enable_denoising={p_enable_denoising}")
print(f"入参:p_enable_color_enhancement={p_enable_color_enhancement}")
print(f"入参:p_fps={fps}")
print(f"入参:p_bitrate={bitrate}")
print(f"入参:p_enable_sharpening={sharpening}")
print(f"入参:p_enable_denoising={denoising}")
print(f"入参:p_enable_color_enhancement={color_enhancement}")
def get_output_name():
"""
根据参数动态生成输出文件名。
如果某些参数有值,则将其拼接到输出名称中。
冒号会被移除。
"""
parts = []
# 检查每个参数是否有值,并拼接到结果中
if not is_null_or_empty(crf):
parts.append(f"crf-{crf}")
if not is_null_or_empty(fps):
parts.append(f"fps-{fps}")
if not is_null_or_empty(bitrate):
parts.append(f"bitrate-{bitrate}")
if not is_null_or_empty(sharpening):
parts.append(f"sharpening-{sharpening}")
if not is_null_or_empty(denoising):
parts.append(f"denoising-{denoising}")
if not is_null_or_empty(color_enhancement):
parts.append(f"color-{color_enhancement}")
# 拼接所有部分,并用 '-' 连接
output_name = "-".join(parts)
# 移除冒号(如果存在)
output_name = output_name.replace(":", "")
return output_name
for gift_path in find_files_by_prefixes("webp_dir", gift_id):
convert_webp_2_mp4.check_file_or_dir(gift_path, "mp4ConvertResult")
convert_webp_2_mp4.check_file_or_dir(gift_path, "mp4ConvertResult", output_name=get_output_name())
for gift_path in find_files_by_prefixes("motoring", motoring_id):
convert_webp_2_mp4.check_file_or_dir(gift_path, "mp4ConvertResult")
convert_webp_2_mp4.check_file_or_dir(gift_path, "mp4ConvertResult", output_name=get_output_name())
print(f"座驾路径{gift_path}")
realpath = f"mp4ConvertResult/{webp_path_or_dir}"
if not is_null_or_empty(realpath):
convert_webp_2_mp4.check_file_or_dir(realpath)
convert_webp_2_mp4.check_file_or_dir(realpath, output_name=get_output_name())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment