Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-10-20 13:38:03 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1aa4502d5fbedda8f78dfcbb99e80cafeba39a3f
1aa4502d
1 parent
33a282e5
for snapshot, choose the best to link to the [stream]-best.png
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
28 行增加
和
5 行删除
trunk/research/api-server/server.py
trunk/research/api-server/server.py
查看文件 @
1aa4502
...
...
@@ -940,8 +940,13 @@ class SrsWorker(cherrypy.process.plugins.SimplePlugin):
print
'abort snapshot
%
s'
%
snapshot
[
'cmd'
]
break
# how many snapshots to output.
vframes
=
6
# the expire in seconds for ffmpeg to snapshot.
expire
=
10
# already snapshoted and not expired.
if
process
is
not
None
and
diff
<
10
:
if
process
is
not
None
and
diff
<
expire
:
continue
# terminate the active process
...
...
@@ -951,17 +956,35 @@ class SrsWorker(cherrypy.process.plugins.SimplePlugin):
# None incidates the process hasn't terminate yet.
if
process
.
returncode
is
not
None
:
# process terminated
, check the returncode
.
# process terminated
with error
.
if
process
.
returncode
!=
0
:
print
'process terminated with error=
%
s, cmd=
%
s'
%
(
process
.
returncode
,
snapshot
[
'cmd'
])
# process terminated normally.
else
:
# guess the best one.
bestsize
=
0
besturl
=
os
.
path
.
join
(
static_dir
,
"
%
s/
%
s-best.png"
%
(
snapshot
[
'app'
],
snapshot
[
'stream'
]))
for
i
in
range
(
0
,
vframes
):
output
=
os
.
path
.
join
(
static_dir
,
"
%
s/
%
s-
%03
d.png"
%
(
snapshot
[
'app'
],
snapshot
[
'stream'
],
i
+
1
))
fsize
=
os
.
path
.
getsize
(
output
)
if
bestsize
<
fsize
:
os
.
system
(
"rm -f '
%
s'"
%
besturl
)
os
.
system
(
"ln -sf '
%
s' '
%
s'"
%
(
output
,
besturl
))
bestsize
=
fsize
print
'the best thumbnail is
%
s'
%
besturl
else
:
# wait for process to terminate, timeout is N*expire.
if
diff
<
10
*
expire
:
continue
# kill the process when user cancel.
else
:
process
.
kill
()
print
'kill the process
%
s'
%
snapshot
[
'cmd'
]
# create new process to snapshot.
ffmpeg
=
"./objs/ffmpeg/bin/ffmpeg"
output
=
os
.
path
.
join
(
static_dir
,
"
%
s-
%
s-
%%3
d.png"
%
(
snapshot
[
'app'
],
snapshot
[
'stream'
]))
cmd
=
'
%
s -i
%
s -vf fps=1/6 -vcodec png -f image2 -an -y -vframes 3 -y
%
s'
%
(
ffmpeg
,
url
,
output
)
output
=
os
.
path
.
join
(
static_dir
,
"
%
s/
%
s-
%%03
d.png"
%
(
snapshot
[
'app'
],
snapshot
[
'stream'
]))
cmd
=
'
%
s -i
%
s -vf fps=1/6 -vcodec png -f image2 -an -y -vframes
%
s -y
%
s'
%
(
ffmpeg
,
url
,
vframes
,
output
)
print
'snapshot by:
%
s'
%
cmd
process
=
create_process
(
cmd
,
discard
.
fileno
(),
discard
.
fileno
())
...
...
@@ -971,7 +994,7 @@ class SrsWorker(cherrypy.process.plugins.SimplePlugin):
pass
;
# {"action":"on_publish","client_id":108,"ip":"127.0.0.1","vhost":"__defaultVhost__","app":"live","stream":"livestream"}
# ffmpeg -i rtmp://127.0.0.1:1935/live?vhost=dev/stream -vf fps=1/6 -vcodec png -f image2 -an -y -vframes 3 -y static-dir/live
-livestream-%
3d.png
# ffmpeg -i rtmp://127.0.0.1:1935/live?vhost=dev/stream -vf fps=1/6 -vcodec png -f image2 -an -y -vframes 3 -y static-dir/live
/livestream-%0
3d.png
def
snapshot_create
(
self
,
req
):
url
=
"rtmp://127.0.0.1/
%
s...vhost...
%
s/
%
s"
%
(
req
[
'app'
],
req
[
'vhost'
],
req
[
'stream'
])
if
url
in
self
.
__snapshots
:
...
...
请
注册
或
登录
后发表评论