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
a2e8181d
Commit
a2e8181d
authored
Mar 30, 2023
by
mac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
c
parent
ed511fe0
Pipeline
#390
canceled with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
testVideo.py
testVideo.py
+14
-7
No files found.
testVideo.py
View file @
a2e8181d
...
@@ -149,7 +149,7 @@ def video2comix(args):
...
@@ -149,7 +149,7 @@ def video2comix(args):
inputmp4
=
jj
(
args
.
input_dir
,
args
.
filename
+
'.mp4'
)
inputmp4
=
jj
(
args
.
input_dir
,
args
.
filename
+
'.mp4'
)
outputmp4
=
jj
(
args
.
output_dir
,
args
.
filename
+
'.mp4'
)
outputmp4
=
jj
(
args
.
output_dir
,
args
.
filename
+
'.mp4'
)
outputh264
=
jj
(
args
.
output_dir
,
args
.
filename
+
'_h264.mp4'
)
outputh264
=
jj
(
args
.
output_dir
,
args
.
filename
+
'_h264.mp4'
)
print
(
'video input: '
,
inputmp4
)
vc
=
cv2
.
VideoCapture
(
inputmp4
)
vc
=
cv2
.
VideoCapture
(
inputmp4
)
print
(
'video open status:'
,
vc
.
isOpened
())
print
(
'video open status:'
,
vc
.
isOpened
())
...
@@ -159,10 +159,6 @@ def video2comix(args):
...
@@ -159,10 +159,6 @@ def video2comix(args):
frame_height
=
int
(
vc
.
get
(
cv2
.
CAP_PROP_FRAME_HEIGHT
))
frame_height
=
int
(
vc
.
get
(
cv2
.
CAP_PROP_FRAME_HEIGHT
))
print
(
'video w,h:'
,
str
(
frame_width
),
','
,
str
(
frame_height
))
print
(
'video w,h:'
,
str
(
frame_width
),
','
,
str
(
frame_height
))
#total frames num
numFrames
=
int
(
vc
.
get
(
cv2
.
CAP_PROP_FRAME_COUNT
))
print
(
'video total Frames num:'
,
str
(
numFrames
))
# fps
# fps
fps
=
int
(
vc
.
get
(
cv2
.
CAP_PROP_FPS
))
fps
=
int
(
vc
.
get
(
cv2
.
CAP_PROP_FPS
))
print
(
'video fps:'
,
str
(
fps
))
print
(
'video fps:'
,
str
(
fps
))
...
@@ -171,6 +167,15 @@ def video2comix(args):
...
@@ -171,6 +167,15 @@ def video2comix(args):
fps_flow
=
int
(
args
.
fps
)
# fps / 2
fps_flow
=
int
(
args
.
fps
)
# fps / 2
print
(
'video output fps:'
,
str
(
fps_flow
))
print
(
'video output fps:'
,
str
(
fps_flow
))
# total frames num
numFrames
=
int
(
vc
.
get
(
cv2
.
CAP_PROP_FRAME_COUNT
))
print
(
'video total Frames num:'
,
str
(
numFrames
))
step
=
fps
/
fps_flow
#根据fps算要跳几帧,比如:24fpx/5fpx=4,即每4帧读取下,1秒大概读取4~5帧
totalNumFrames
=
numFrames
/
step
print
(
'video output total Frames num:'
,
str
(
totalNumFrames
))
# MPEG can not play in web
# MPEG can not play in web
fourcc
=
cv2
.
VideoWriter_fourcc
(
*
'MP4V'
)
#H264 avc1
fourcc
=
cv2
.
VideoWriter_fourcc
(
*
'MP4V'
)
#H264 avc1
...
@@ -181,8 +186,8 @@ def video2comix(args):
...
@@ -181,8 +186,8 @@ def video2comix(args):
print
(
'video output w,h:'
,
str
(
wh
))
print
(
'video output w,h:'
,
str
(
wh
))
flow_video
=
cv2
.
VideoWriter
(
outputmp4
,
fourcc
,
fps_flow
,
wh
)
flow_video
=
cv2
.
VideoWriter
(
outputmp4
,
fourcc
,
fps_flow
,
wh
)
i
=
0
i
=
0
step
=
fps
/
fps_flow
#根据fps算要跳几帧,比如:24fpx/5fpx=4,即每4帧读取下,1秒大概读取4~5帧
n
=
0
#帧数
n
=
0
#帧数
totalTime
=
0
imgname
=
uuid
.
uuid4
()
.
hex
imgname
=
uuid
.
uuid4
()
.
hex
while
vc
.
isOpened
():
while
vc
.
isOpened
():
vc
.
set
(
cv2
.
CAP_PROP_POS_FRAMES
,
n
)
# 截取指定帧数
vc
.
set
(
cv2
.
CAP_PROP_POS_FRAMES
,
n
)
# 截取指定帧数
...
@@ -212,6 +217,8 @@ def video2comix(args):
...
@@ -212,6 +217,8 @@ def video2comix(args):
#print('---------style_frame type=' , type(style_frame))
#print('---------style_frame type=' , type(style_frame))
if
i
==
0
:
if
i
==
0
:
print
(
'----------one frame time:'
,
stylization_time
,
', style_frame type:'
,
type
(
style_frame
),
',size'
,
style_frame
.
shape
)
print
(
'----------one frame time:'
,
stylization_time
,
', style_frame type:'
,
type
(
style_frame
),
',size'
,
style_frame
.
shape
)
print
(
'frames:'
,
i
,
' / '
,
totalNumFrames
,
'time:'
,
stylization_time
)
totalTime
=
totalTime
+
stylization_time
#img = np.asarray(style_frame)
#img = np.asarray(style_frame)
flow_video
.
write
(
style_frame
.
astype
(
'uint8'
))
flow_video
.
write
(
style_frame
.
astype
(
'uint8'
))
#flow_video.write(cv2.cvtColor(img,cv2.COLOR_RGB2BGR).astype('uint8')) #COLOR_BGR2RGB
#flow_video.write(cv2.cvtColor(img,cv2.COLOR_RGB2BGR).astype('uint8')) #COLOR_BGR2RGB
...
@@ -223,7 +230,7 @@ def video2comix(args):
...
@@ -223,7 +230,7 @@ def video2comix(args):
flow_video
.
release
()
flow_video
.
release
()
vc
.
release
()
vc
.
release
()
#call(["ffmpeg", "-i", outputmp4, "-vcodec", "libx264", "-f", "mp4", outputh264])
#call(["ffmpeg", "-i", outputmp4, "-vcodec", "libx264", "-f", "mp4", outputh264])
print
(
'finish
'
)
print
(
'finish
, totalTime= '
,
totalTime
)
return
0
return
0
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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