Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
animegan2-pytorch
Project
Project
Details
Activity
Releases
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
git
animegan2-pytorch
Commits
6ae75e37
Commit
6ae75e37
authored
Mar 30, 2023
by
mac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c
parent
a2e8181d
Pipeline
#391
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
9 deletions
+35
-9
testVideo.py
testVideo.py
+35
-9
No files found.
testVideo.py
View file @
6ae75e37
...
...
@@ -135,6 +135,11 @@ def video2comix(args):
print
(
'miss param: filename'
)
return
i
=
0
#写入的帧数计数值
readFrameNum
=
0
#要读取的帧数
totalTime
=
0
#总时间
device
=
args
.
device
net
=
Generator
()
...
...
@@ -172,9 +177,14 @@ def video2comix(args):
print
(
'video total Frames num:'
,
str
(
numFrames
))
step
=
fps
/
fps_flow
#根据fps算要跳几帧,比如:24fpx/5fpx=4,即每4帧读取下,1秒大概读取4~5帧
totalNumFrames
=
numFrames
/
step
totalNumFrames
=
int
(
numFrames
/
step
)
print
(
'video output total Frames num:'
,
str
(
totalNumFrames
))
if
args
.
total_seconds
!=
0
:
totalNumFrames
=
int
(
args
.
seconds
*
fps_flow
)
if
args
.
start_seconds
!=
0
:
readFrameNum
=
int
(
args
.
start_seconds
*
fps
)
# MPEG can not play in web
...
...
@@ -185,17 +195,17 @@ def video2comix(args):
wh
=
(
to_32s
(
frame_width
),
to_32s
(
frame_height
))
print
(
'video output w,h:'
,
str
(
wh
))
flow_video
=
cv2
.
VideoWriter
(
outputmp4
,
fourcc
,
fps_flow
,
wh
)
i
=
0
n
=
0
#帧数
totalTime
=
0
imgname
=
uuid
.
uuid4
()
.
hex
while
vc
.
isOpened
():
vc
.
set
(
cv2
.
CAP_PROP_POS_FRAMES
,
n
)
# 截取指定帧数
n
=
n
+
step
#跳帧
if
n
>=
numFrames
:
print
(
'video2comix - read frame is over'
)
vc
.
set
(
cv2
.
CAP_PROP_POS_FRAMES
,
readFrameNum
)
# 截取指定帧数
readFrameNum
=
readFrameNum
+
step
#跳帧
if
readFrameNum
>=
numFrames
:
print
(
'video2comix - read totalNumframes is over'
)
break
if
i
>=
totalNumFrames
:
print
(
'video2comix - output totalNumFrames is over'
)
break
su
,
frame
=
vc
.
read
()
if
frame
is
None
:
print
(
'video2comix - read frame is none'
)
...
...
@@ -279,6 +289,22 @@ if __name__ == '__main__':
help
=
"fps >0 and < 20"
)
parser
.
add_argument
(
'--total_seconds'
,
type
=
int
,
default
=
5
,
help
=
"senonds >= 0 and < 60"
)
parser
.
add_argument
(
'--start_seconds'
,
type
=
int
,
default
=
0
,
help
=
"senonds >= 0 and < 60"
)
args
=
parser
.
parse_args
()
time
=
video2comix
(
args
)
...
...
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