Commit 9baedcb0 by xiaoqi

requirements

parent 5a0c3249
Showing with 6 additions and 46 deletions
......@@ -6,11 +6,9 @@ import shutil
import subprocess
import tempfile
import time
import traceback
from pathlib import Path
import appdirs
import numpy as np
from PIL import Image, ImageEnhance, UnidentifiedImageError
from PIL import Image, ImageEnhance
from moviepy import *
from moviepy import VideoFileClip, clips_array
......@@ -445,10 +443,6 @@ def webp2mp4core(input_webp_path_str, output_name: str = None):
# 合并视频并清理临时文件
merge_videos_side_by_side(temp_output_alpha_video_path, temp_normal_output_video_path, output_merge_video_path)
print(f"两个视频合并完成,保存在{output_merge_video_path},开始删除临时文件")
# delete_path(temp_output_alpha_video_path)
# delete_path(temp_png_dir)
# delete_path(temp_normal_output_video_path)
# delete_path(temp_png_alpha_dir)
# 注意:这里假设其他所需函数(如webp2png, convert_to_grayscale, png2mp4, get_fps, merge_videos_side_by_side, delete_path)已经定义。
......@@ -488,47 +482,10 @@ if __name__ == '__main__':
inputDirOrFile = inputDirOrFile.replace("\"", "")
# inputDirOrFile = "I:/test/test.webp"
start_time = time.time()
# p_ffmpeg_params = ["-crf", "1", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数1")
# p_ffmpeg_params = ["-crf", "2", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数2")
# p_ffmpeg_params = ["-crf", "3", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数3")
# p_ffmpeg_params = ["-crf", "5", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数5")
# p_ffmpeg_params = ["-crf", "7", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数7")
# p_ffmpeg_params = ["-crf", "9", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数9")
# p_ffmpeg_params = ["-crf", "12", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数12")
# p_ffmpeg_params = ["-crf", "15", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数15")
# p_ffmpeg_params = ["-crf", "18", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数18")
# p_ffmpeg_params = ["-crf", "20", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数20")
p_vf = generate_vf_params(convert_fps_24=False, convert_to_hdr=False, enable_sharpening=False,
enable_denoising=True, enable_color_enhancement=False)
print(f"pvf={p_vf}")
check_file_or_dir(inputDirOrFile, "降噪")
# p_vf = ""
# check_file_or_dir(inputDirOrFile, "不插帧")
# p_codec = "libx264"
# p_preset = "ultrafast"
# check_file_or_dir(inputDirOrFile, "ultrafast")
# p_ffmpeg_params = ["-crf", "24", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数24")
# p_ffmpeg_params = ["-crf", "26", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数26")
# p_ffmpeg_params = ["-crf", "28", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数28")
# p_ffmpeg_params = ["-crf", "30", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数30")
# p_ffmpeg_params = ["-crf", "32", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数32")
# p_ffmpeg_params = ["-crf", "34", "-pix_fmt", "yuv444p", "-tune", "animation"]
# check_file_or_dir(inputDirOrFile, "质量参数34")
print(f"耗时:{time.time() - start_time}秒")
print(f"mp4大小:{mp4_size_total}")
print(f"webp大小:{webp_size_total}")
# -*- coding: utf-8 -*-
import sys
import convert_webp_2_mp4
# sys.argv 是一个列表,第一个元素是脚本名,后续是传递的参数
script_name = sys.argv[0] # 脚本名
webp_path_or_dir = sys.argv[1] # 第一个参数
crf = sys.argv[2] # 第一个参数
# convert_webp_2_mp4.p_crf = crf
# convert_webp_2_mp4.check_file_or_dir(webp_path_or_dir)
convert_webp_2_mp4.p_crf = crf
convert_webp_2_mp4.check_file_or_dir(webp_path_or_dir)
print(f"shurude={crf} dir={webp_path_or_dir}")
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