Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
xiaoqi
/
mp4giftconvert
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9baedcb0
authored
Apr 11, 2025
by
xiaoqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
requirements
parent
5a0c3249
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
46 deletions
convert_webp_2_mp4.py
go.py
convert_webp_2_mp4.py
View file @
9baedcb0
...
...
@@ -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}"
)
go.py
View file @
9baedcb0
# -*- 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}"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment