Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Hypo
ShellPlayer
提交
47baf87d
S
ShellPlayer
项目概览
Hypo
/
ShellPlayer
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
ShellPlayer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
47baf87d
编写于
6月 12, 2020
作者:
H
hypox64
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support Windows
上级
15359ca7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
23 deletion
+33
-23
img2shell.py
img2shell.py
+1
-1
options.py
options.py
+1
-1
play.py
play.py
+31
-21
未找到文件。
img2shell.py
浏览文件 @
47baf87d
...
...
@@ -102,7 +102,7 @@ class Transformer(object):
def
pixel_color
(
self
,
Y
,
dis
):
if
Y
<
24
:
if
Y
<
32
:
return
' '
# color
...
...
options.py
浏览文件 @
47baf87d
...
...
@@ -9,7 +9,7 @@ class Options():
self
.
parser
.
add_argument
(
'-m'
,
'--media'
,
type
=
str
,
default
=
'./imgs/test.jpg'
,
help
=
'your video or image path'
)
self
.
parser
.
add_argument
(
'-g'
,
'--gray'
,
action
=
'store_true'
,
help
=
'if specified, play gray video'
)
self
.
parser
.
add_argument
(
'-f'
,
'--fps'
,
type
=
int
,
default
=
0
,
help
=
'playing fps, 0-> auto'
)
self
.
parser
.
add_argument
(
'-c'
,
'--charstyle'
,
type
=
int
,
default
=
3
,
help
=
'style of output'
)
self
.
parser
.
add_argument
(
'-c'
,
'--charstyle'
,
type
=
int
,
default
=
1
,
help
=
'style of output'
)
self
.
parser
.
add_argument
(
'-s'
,
'--screen'
,
type
=
int
,
default
=
1
,
help
=
'size of shell 1:80*24 2:132*43 3:203*55'
)
self
.
parser
.
add_argument
(
'--ori_fps'
,
type
=
int
,
default
=
0
,
help
=
'original fps for video, 0-> auto'
)
...
...
play.py
浏览文件 @
47baf87d
import
os
import
sys
import
time
import
multiprocessing
from
multiprocessing
import
Process
,
Queue
import
threading
import
subprocess
import
numpy
as
np
import
cv2
import
platform
from
util
import
util
,
ffmpeg
from
img2shell
import
Transformer
...
...
@@ -30,6 +32,9 @@ def timer(opt,timerQueueime):
timerQueueime
.
put
(
True
)
opt
=
Options
().
getparse
()
system_type
=
'Linux'
if
'Windows'
in
platform
.
platform
():
system_type
=
'Windows'
#-------------------------------Media Init-------------------------------
if
util
.
is_img
(
opt
.
media
):
...
...
@@ -41,7 +46,7 @@ elif util.is_video(opt.media):
opt
.
frame_num
=
int
(
endtime
*
fps
-
5
)
if
opt
.
ori_fps
==
0
:
opt
.
ori_fps
=
fps
util
.
clean_tempfiles
(
tmp_init
=
True
)
util
.
makedirs
(
'./tmp'
)
else
:
print
(
'Can not load this file!'
)
...
...
@@ -68,29 +73,34 @@ if util.is_video(opt.media):
opt
.
fps
=
np
.
clip
(
recommend_fps
,
1
,
opt
.
ori_fps
)
else
:
opt
.
fps
=
np
.
clip
(
opt
.
fps
,
1
,
opt
.
ori_fps
)
ffmpeg
.
video2voice
(
opt
.
media
,
'-ar 16000 ./tmp/tmp.wav'
)
if
system_type
==
'Linux'
:
ffmpeg
.
video2voice
(
opt
.
media
,
'-ar 16000 ./tmp/tmp.wav'
)
#-------------------------------main-------------------------------
if
util
.
is_img
(
opt
.
media
):
print
(
transformer
.
convert
(
img
,
opt
.
gray
))
elif
util
.
is_video
(
opt
.
media
):
imgQueue
=
Queue
(
1
)
timerQueue
=
Queue
()
if
__name__
==
'__main__'
:
if
system_type
==
'Windows'
:
multiprocessing
.
freeze_support
()
if
util
.
is_img
(
opt
.
media
):
print
(
transformer
.
convert
(
img
,
opt
.
gray
))
elif
util
.
is_video
(
opt
.
media
):
imgQueue
=
Queue
(
1
)
timerQueue
=
Queue
()
imgload_p
=
Process
(
target
=
readvideo
,
args
=
(
opt
,
imgQueue
))
imgload_p
.
daemon
=
True
imgload_p
.
start
()
imgload_p
=
Process
(
target
=
readvideo
,
args
=
(
opt
,
imgQueue
))
imgload_p
.
daemon
=
True
imgload_p
.
start
()
timer_p
=
Process
(
target
=
timer
,
args
=
(
opt
,
timerQueue
))
timer_p
.
daemon
=
True
timer_p
.
start
()
timer_p
=
Process
(
target
=
timer
,
args
=
(
opt
,
timerQueue
))
timer_p
.
daemon
=
True
timer_p
.
start
()
time
.
sleep
(
0.5
)
subprocess
.
Popen
(
'paplay ./tmp/tmp.wav'
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
time
.
sleep
(
0.5
)
if
system_type
==
'Linux'
:
subprocess
.
Popen
(
'paplay ./tmp/tmp.wav'
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
for
i
in
range
(
int
(
opt
.
frame_num
*
opt
.
fps
/
opt
.
ori_fps
)
-
1
):
timerQueue
.
get
()
img
=
imgQueue
.
get
()
string
=
transformer
.
convert
(
img
,
opt
.
gray
)
t
=
threading
.
Thread
(
target
=
print
,
args
=
(
string
,))
t
.
start
()
for
i
in
range
(
int
(
opt
.
frame_num
*
opt
.
fps
/
opt
.
ori_fps
)
-
1
):
timerQueue
.
get
()
img
=
imgQueue
.
get
()
string
=
transformer
.
convert
(
img
,
opt
.
gray
)
t
=
threading
.
Thread
(
target
=
print
,
args
=
(
string
,))
t
.
start
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录