Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pitube
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
pitube
Commits
dd3f07d4
Verified
Commit
dd3f07d4
authored
4 years ago
by
Andrej Ramašeuski
Browse files
Options
Downloads
Patches
Plain Diff
Rizeni nahravani parametrem v rtmp push url
parent
c41e5432
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#1437
failed
4 years ago
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/PiTube/Controller/Nginx.pm
+21
-1
21 additions, 1 deletion
lib/PiTube/Controller/Nginx.pm
nginx.conf
+25
-28
25 additions, 28 deletions
nginx.conf
pi_tube.conf
+3
-0
3 additions, 0 deletions
pi_tube.conf
with
49 additions
and
29 deletions
lib/PiTube/Controller/Nginx.pm
+
21
−
1
View file @
dd3f07d4
package
PiTube::Controller::
Nginx
;
use
Mojo::
Base
'
Mojolicious::Controller
';
use
Mojo::
UserAgent
;
use
Mojo::
IOLoop
;
use
constant
HLS
=>
qr/^\/
hls
\
/([a-z0-9\-]+)(_\w+)?(\/\w+)?\.(m3u8|ts)$/i
;
...
...
@@ -7,10 +9,11 @@ sub callback_rtmp {
my
$c
=
shift
;
if
(
$c
->
param
('
call
')
=~
/publish/
)
{
my
$name
=
$c
->
param
('
name
');
# stream
my
$stream
=
$c
->
schema
->
resultset
('
Stream
')
->
find
({
key
=>
$
c
->
param
('
name
')
key
=>
$name
,
});
$c
->
render
(
status
=>
404
,
text
=>
''
),
return
if
!
$stream
;
...
...
@@ -20,15 +23,32 @@ sub callback_rtmp {
});
$c
->
render
(
status
=>
403
,
text
=>
''),
return
if
!
$user
;
# TODO: autorizace user/stream
# aktualizace stavu streamu
$stream
->
update
({
publish_last
=>
'
\now()
',
publish_user_id
=>
$user
->
id
,
publish_time
=>
(
$c
->
param
('
time
')
//
0
),
});
# zapnuti nahravani
if
(
$c
->
param
('
record
')
&&
$c
->
param
('
record
')
=~
/(all|audio)/
)
{
my
$record
=
$
1
;
my
$ua
=
Mojo::
UserAgent
->
new
;
Mojo::
IOLoop
->
timer
(
1
=>
sub
($loop) {
my
$res
=
$ua
->
get
(
$c
->
config
->
{
nginx
}{
base_url
}
.
"
/control/record/start?app=stream&name=
$name
&rec=
$record
"
);
});
}
}
$c
->
render
(
status
=>
204
,
text
=>
''
);
}
sub
callback_hls
{
...
...
This diff is collapsed.
Click to expand it.
nginx.conf
+
25
−
28
View file @
dd3f07d4
...
...
@@ -14,42 +14,35 @@ rtmp {
application
stream
{
live
on
;
on_publish
http://pitube:3000/callback/rtmp
;
on_publish
http://pitube:3000/callback/rtmp
;
on_publish_done
http://pitube:3000/callback/rtmp
;
on_update
http://pitube:3000/callback/rtmp
;
notify_update_timeout
15s
;
# -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 1000k -f flv -g 30 -r 30 -s 854x480 -preset superfast -profile:v baseline
# rtmp://localhost:1935/hls/$name_480p1128kbs
# -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 750k -f flv -g 30 -r 30 -s 640x360 -preset superfast -profile:v baseline
# rtmp://localhost:1935/hls/$name_360p878kbs
# -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 400k -f flv -g 30 -r 30 -s 426x240 -preset superfast -profile:v baseline
# rtmp://localhost:1935/hls/$name_240p528kbs
exec
ffmpeg
-i
rtmp://localhost:1935/stream/
$name
-c:a
libfdk_aac
-b:a
128k
-c:v
libx264
-b:v
2500k
-f
flv
-g
30
-r
30
-s
1280x720
-preset
superfast
-profile:v
baseline
rtmp://localhost:1935/hls/
$name_720p2628kbs
-c:a
libfdk_aac
-b:a
64k
-c:v
libx264
-b:v
200k
-f
flv
-g
15
-r
15
-s
426x240
-preset
superfast
-profile:v
baseline
rtmp://localhost:1935/hls/
$name_240p264kbs
;
hls
on
;
hls_path
/tmp/hls
;
hls_fragment
15s
;
recorder
all
{
record
all
manual
;
record_suffix
-%y%m%d-%h%m%s.flv
;
record_path
/tmp
;
record_unique
on
;
record_max_size
4000m
;
}
recorder
audio
{
record
audio
manual
;
record_suffix
-%y%m%d-%h%m%s.audio.flv
;
record_path
/tmp
;
record_unique
on
;
record_max_size
500m
;
}
application
hls
{
live
on
;
hls
on
;
hls_fragment_naming
system
;
hls_fragment
5
;
hls_playlist_length
10
;
hls_path
/tmp/hls
;
hls_nested
on
;
hls_variant
_720p2628kbs
BANDWIDTH=2628000,RESOLUTION=1280x720
;
# hls_variant _480p1128kbs BANDWIDTH=1128000,RESOLUTION=854x480;
# hls_variant _360p878kbs BANDWIDTH=878000,RESOLUTION=640x360;
# hls_variant _240p528kbs BANDWIDTH=528000,RESOLUTION=426x240;
hls_variant
_240p264kbs
BANDWIDTH=264000,RESOLUTION=426x240
;
}
}
}
...
...
@@ -64,8 +57,12 @@ http {
server
{
listen
$
{
HTTP_PORT
}
;
location
/control
{
rtmp_control
all
;
}
location
/hls
{
auth_request
/callback/hls
;
#
auth_request /callback/hls;
alias
/tmp/hls
;
types
{
application/vnd.apple.mpegurl
m3u8
;
...
...
This diff is collapsed.
Click to expand it.
pi_tube.conf
+
3
−
0
View file @
dd3f07d4
...
...
@@ -32,5 +32,8 @@
},
rtmp
=> {
base_url
=> $
ENV
{
RTMP_BASE_URL
},
},
nginx
=> {
base_url
=> $
ENV
{
NGINX_BASE_URL
} //
'http://nginx-rtmp'
,
}
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment