Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
waae-algorithm-tools
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈铭(23研)
waae-algorithm-tools
Commits
45596338
Commit
45596338
authored
Feb 25, 2025
by
wux51
Browse files
Options
Browse Files
Download
Plain Diff
update
parents
1bb844f0
f84612eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
8 deletions
+32
-8
README.md
README.md
+4
-0
script_video.py
script_video.py
+28
-8
No files found.
README.md
0 → 100644
View file @
45596338
# waae-algorithm-tools
waae工具
\ No newline at end of file
script_video.py
View file @
45596338
...
...
@@ -5,6 +5,7 @@ import os.path as osp
import
shutil
from
datetime
import
date
from
collections
import
defaultdict
as
dd
from
moviepy
import
ImageSequenceClip
import
pandas
as
pd
...
...
@@ -43,12 +44,14 @@ def process_data(data, entry):
def
process_page
(
data
,
page_id
):
# 根据page_id,确定页面截图和主page的路径
page
=
data
[
int
(
page_id
)]
screenshot_path
=
[]
screenshot_path
=
[
os
.
path
.
basename
(
box
[
"local_image_path_full"
])
for
box
in
page
[
"focus_boxes"
]]
image_path
=
page
[
'img_path'
]
return
screenshot_path
,
image_path
def
process
(
file_list
,
data
,
entry
,
img
_save_path
,
save_path
):
def
process
(
file_list
,
data
,
entry
,
video
_save_path
,
save_path
):
result_finial
=
{}
cnt
=
0
...
...
@@ -60,6 +63,8 @@ def process(file_list, data, entry, img_save_path, save_path):
try
:
errors
=
report
[
'check_result'
][
'errors'
]
pages
=
report
[
'check_result'
][
'pages'
]
app_name
=
report
[
'appName'
]
task_id
=
report
[
'hcTaskId'
]
except
:
continue
for
k
in
errors
:
...
...
@@ -78,10 +83,18 @@ def process(file_list, data, entry, img_save_path, save_path):
for
page_id
in
result
:
id
=
f
'{save_path}_{cnt}'
video_path
=
osp
.
join
(
'todo'
,
f
'{
id}.mp4'
)
video_path
=
osp
.
join
(
video_save_path
,
f
'{app_name}-{task_id}-{page_
id}.mp4'
)
screenshot_path
,
image_path
=
process_page
(
pages
,
page_id
)
image_path
=
osp
.
join
(
file
,
'screenshots'
,
image_path
.
split
(
'/'
)[
-
1
])
img_path
=
osp
.
join
(
img_save_path
,
f
'{id}.png'
)
img_path
=
osp
.
join
(
save_path
,
f
'{id}.png'
)
# 当前页面的所有截图
screenshot_path
=
[
osp
.
join
(
file
,
'screenshots'
,
item
)
for
item
in
screenshot_path
]
# 合成视频
images_to_video
(
screenshot_path
,
video_path
,
fps
=
1
)
result_finial
[
id
]
=
{
'页面名'
:
f
'{id}'
,
'合成视频路径'
:
video_path
,
'页面截图路径'
:
image_path
,
'所有截图路径'
:
screenshot_path
}
...
...
@@ -103,18 +116,23 @@ def load_file_path(path):
return
file_list
def
images_to_video
(
image_files
,
output_video_path
,
fps
=
1
):
clip
=
ImageSequenceClip
(
image_files
,
fps
=
fps
)
clip
.
write_videofile
(
output_video_path
)
print
(
f
"视频已成功保存至:{output_video_path}"
)
def
run
(
path
=
'/AIAssd/aia/waae/tasks
'
):
def
run
(
tast_dir
=
'task_dir'
,
map_dict_path
=
'app_video_map.txt
'
):
save_path
=
str
(
date
.
today
())
.
replace
(
'-'
,
'_'
)
video_save_path
=
osp
.
join
(
save_path
,
'videos'
)
report_save_path
=
osp
.
join
(
save_path
,
'app_video_report.json'
)
report_save_path_excel
=
osp
.
join
(
save_path
,
'app_video_report.xlsx'
)
os
.
makedirs
(
video_save_path
,
exist_ok
=
True
)
file_list
=
load_file_path
(
path
)
print
(
len
(
file_list
))
file_list
=
load_file_path
(
tast_dir
)
with
open
(
'app_video_map.txt'
,
'r'
)
as
f
:
with
open
(
map_dict_path
,
'r'
)
as
f
:
data1
=
f
.
readlines
()
data
=
dd
(
list
)
keys
=
dd
()
...
...
@@ -139,4 +157,5 @@ def run(path='/AIAssd/aia/waae/tasks'):
create_excel_with_columns
(
result_finial
,
report_save_path_excel
)
if
__name__
==
'__main__'
:
# TODO: 使用时,传入waae数据根目录(task_dir)和检测的条目(app_video_map.txt)
run
()
\ No newline at end of file
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