dirty support for 0.8.0 - osp-rtmp daemon
This commit is contained in:
		
							parent
							
								
									fde33a766a
								
							
						
					
					
						commit
						c6a9c1ced5
					
				|  | @ -1,7 +1,8 @@ | |||
| --- | ||||
| osp_git_root: 'https://gitlab.com/Deamos/flask-nginx-rtmp-manager.git' | ||||
| osp_git_commit: '0.7.9' | ||||
| osp_worker_start_port: 5000 | ||||
| osp_worker_rtmp_port: 5999 | ||||
| osp_worker_start_port: 5010 | ||||
| osp_worker_count: "{{ ansible_processor_nproc }}" | ||||
| osp_worker_timeout: 30 | ||||
| # should not be edited | ||||
|  |  | |||
|  | @ -22,3 +22,9 @@ | |||
|     name: osp.target | ||||
|     state: restarted | ||||
|     daemon_reload: yes | ||||
| 
 | ||||
| - name: restart osp-rtmp | ||||
|   systemd: | ||||
|     name: osp-rtmp | ||||
|     state: restarted | ||||
|     daemon_reload: yes | ||||
|  |  | |||
|  | @ -165,6 +165,13 @@ | |||
|     dest: "/opt/osp/conf/config.py" | ||||
|     state: link | ||||
| 
 | ||||
| - name: Configure supply rtmp | ||||
|   notify: restart osp-rtmp | ||||
|   file: | ||||
|     src: "/etc/osp.conf" | ||||
|     dest: "/opt/osp/installs/osp-rtmp/conf/config.py" | ||||
|     state: link | ||||
| 
 | ||||
| - name: Create logging directory | ||||
|   file: | ||||
|     path: /opt/osp | ||||
|  | @ -198,9 +205,14 @@ | |||
|   loop: | ||||
|     - osp-worker@.service | ||||
|     - osp.target | ||||
|     - osp-rtmp.service | ||||
| 
 | ||||
| - name: Start OSP | ||||
|   systemd: | ||||
|     name: osp.target | ||||
|     name: "{{ item }}" | ||||
|     state: started | ||||
|     enabled: yes | ||||
|   loop: | ||||
|     - osp.target | ||||
|     - osp-rtmp.service | ||||
|     - osp.target | ||||
|  |  | |||
|  | @ -24,6 +24,8 @@ requireEmailRegistration={{ osp_require_email_registration }} | |||
| # Enables Debug Mode | ||||
| debugMode = False | ||||
| 
 | ||||
| ospCoreAPI = "http://127.0.0.1:{{ osp_worker_start_port }}" | ||||
| 
 | ||||
| # EJabberD Configuration | ||||
| ejabberdAdmin = "admin" | ||||
| ejabberdPass = "{{ osp_ejabberd_password }}" | ||||
|  |  | |||
|  | @ -161,7 +161,7 @@ shaper_rules: | |||
| 
 | ||||
| auth_use_cache: false | ||||
| auth_password_format: scram | ||||
| extauth_program: "/usr/bin/python3 /opt/osp/setup/ejabberd/auth_osp.py" | ||||
| extauth_program: "/usr/bin/python3 /opt/osp/installs/ejabberd/setup/auth_osp.py" | ||||
| extauth_instances: 3 | ||||
| 
 | ||||
| host_config: | ||||
|  |  | |||
|  | @ -67,9 +67,7 @@ http { | |||
|         # sticky cookie srv_id expires=8h; | ||||
|         hash $remote_addr consistent; | ||||
| {% for n in range(osp_worker_count) %} | ||||
| {% if n != 0 or osp_worker_count == 1 %} | ||||
|         server 127.0.0.1:{{ osp_worker_start_port + n }}; | ||||
| {% endif %} | ||||
| {% endfor %} | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -106,12 +106,12 @@ | |||
| 
 | ||||
|         location /edge { | ||||
|             auth_request /ospAuth; | ||||
|             rewrite ^/edge/(.*)$ $scheme://$ospedge_node/live/$1 redirect; | ||||
|             rewrite ^/edge/(.*)$ $scheme://$ospedge_node/edge/$1 redirect; | ||||
|         } | ||||
| 
 | ||||
|         location /edge-adapt { | ||||
|             auth_request /ospAuth; | ||||
|             rewrite ^/edge-adapt/(.*)$ $scheme://$ospedge_node/live-adapt/$1 redirect; | ||||
|             rewrite ^/edge-adapt/(.*)$ $scheme://$ospedge_node/edge-adapt/$1 redirect; | ||||
|         } | ||||
| 
 | ||||
|         location /http-bind/ {              # BOSH XMPP-HTTP | ||||
|  |  | |||
|  | @ -6,6 +6,9 @@ rtmp { | |||
|                 #listen 1935; | ||||
|                 listen [::]:1935; | ||||
|                 chunk_size 4096; | ||||
|                 ping 30s; | ||||
|                 ping_timeout 15s; | ||||
|                 drop_idle_publisher 15s; | ||||
| 
 | ||||
|                 application stream { | ||||
|                         live on; | ||||
|  | @ -17,8 +20,8 @@ rtmp { | |||
|                         allow play 127.0.0.1; | ||||
|                         deny play all; | ||||
| 
 | ||||
|                         on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-key; | ||||
|                         on_publish_done http://127.0.0.1:{{ osp_worker_start_port }}/deauth-user; | ||||
|                         on_publish http://127.0.0.1:{{ osp_worker_rtmp_port }}/auth-key; | ||||
|                         on_publish_done http://127.0.0.1:{{ osp_worker_rtmp_port }}/deauth-user; | ||||
| 
 | ||||
|                 } | ||||
|                 application stream-data { | ||||
|  | @ -30,17 +33,18 @@ rtmp { | |||
|                         allow play 127.0.0.1; | ||||
|                         deny play all; | ||||
| 
 | ||||
|                         on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-user; | ||||
|                         on_publish http://127.0.0.1:{{ osp_worker_rtmp_port }}/auth-user; | ||||
|                         push rtmp://127.0.0.1:1935/live/; | ||||
|                         push rtmp://127.0.0.1:1935/record/; | ||||
| 
 | ||||
|                         hls on; | ||||
|                         hls_path {{ osp_http_path }}/live; | ||||
|                         hls_fragment 1; | ||||
|                         hls_playlist_length 30s; | ||||
|                         #hls_playlist_length 30s; | ||||
|                         hls_playlist_length 30m; | ||||
| 
 | ||||
|                         hls_nested on; | ||||
|                         hls_fragment_naming system; | ||||
|                         hls_fragment_naming sequential; | ||||
| 
 | ||||
|                         recorder thumbnail { | ||||
|                             record video; | ||||
|  | @ -62,12 +66,12 @@ rtmp { | |||
|                         allow play 127.0.0.1; | ||||
|                         deny play all; | ||||
| 
 | ||||
|                         on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-user; | ||||
|                         on_publish http://127.0.0.1:{{ osp_worker_rtmp_port }}/auth-user; | ||||
|                         push rtmp://127.0.0.1:1935/live/; | ||||
|                         push rtmp://127.0.0.1:1935/record/; | ||||
| 
 | ||||
|                         exec ffmpeg -i rtmp://127.0.0.1:1935/live/$name | ||||
|                                 -c:v libx264 -c:a aac -b:a 192k -vf "scale=-2:1080" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 4192k -bufsize 8384k -threads 4 -f flv rtmp://127.0.0.1:1935/show/$name_1080 | ||||
|                                 # -c:v libx264 -c:a aac -b:a 192k -vf "scale=-2:1080" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 4192k -bufsize 8384k -threads 4 -f flv rtmp://127.0.0.1:1935/show/$name_1080 | ||||
|                                 -c:v libx264 -c:a aac -b:a 128k -vf "scale=-2:720" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 2096k -bufsize 4192k -threads 4 -f flv rtmp://127.0.0.1:1935/show/$name_720 | ||||
|                                 -c:v libx264 -c:a aac -b:a 96k -vf "scale=-2:480" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 1200k -bufsize 2400k -threads 4 -f flv rtmp://127.0.0.1:1935/show/$name_480; | ||||
|                                 # -c copy -f flv rtmp://127.0.0.1:1935/show/$name_src; | ||||
|  | @ -98,9 +102,10 @@ rtmp { | |||
|                         hls_path {{ osp_http_path }}/live-adapt; | ||||
|                         hls_nested on; | ||||
|                         hls_fragment 1; | ||||
|                         hls_playlist_length 30s; | ||||
|                         #hls_playlist_length 30s; | ||||
|                         hls_playlist_length 30m; | ||||
| 
 | ||||
|                         hls_fragment_naming system; | ||||
|                         hls_fragment_naming sequential; | ||||
| 
 | ||||
|                         record off; | ||||
| 
 | ||||
|  | @ -121,7 +126,7 @@ rtmp { | |||
|                         allow play 127.0.0.1; | ||||
|                         deny play all; | ||||
| 
 | ||||
|                         on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-record; | ||||
|                         on_publish http://127.0.0.1:{{ osp_worker_rtmp_port }}/auth-record; | ||||
|                         exec_push mkdir -m 764 {{ osp_http_path }}/videos/$name; | ||||
| 
 | ||||
|                         recorder all { | ||||
|  | @ -132,19 +137,18 @@ rtmp { | |||
|                             exec_record_done bash -c "ffmpeg -y -i $path -codec copy -movflags +faststart {{ osp_http_path }}/videos/$name/$basename.mp4 && rm $path"; | ||||
|                             exec_record_done mv {{ osp_http_path }}/stream-thumb/$name.png {{ osp_http_path }}/videos/$name/$basename.png; | ||||
|                             exec_record_done mv {{ osp_http_path }}/stream-thumb/$name.gif {{ osp_http_path }}/videos/$name/$basename.gif; | ||||
|                             on_record_done http://127.0.0.1:{{ osp_worker_start_port }}/deauth-record; | ||||
|                             on_record_done http://127.0.0.1:{{ osp_worker_rtmp_port }}/deauth-record; | ||||
|                         } | ||||
|                 } | ||||
| 
 | ||||
|                 application live { | ||||
|                         live on; | ||||
|                         drop_idle_publisher 30s; | ||||
|                         allow publish ::1; | ||||
|                         allow publish 127.0.0.1; | ||||
|                         deny publish all; | ||||
|                         allow play all; | ||||
| 
 | ||||
|                         on_play http://127.0.0.1:{{ osp_worker_start_port }}/playbackAuth; | ||||
|                         on_play http://127.0.0.1:{{ osp_worker_rtmp_port }}/playbackAuth; | ||||
|                 } | ||||
|         } | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,24 @@ | |||
| [Unit] | ||||
| Description=Gunicorn instance to serve OSP-RTMP | ||||
| After=network.target ejabberd.service redis.service | ||||
| PartOf=osp.target | ||||
| 
 | ||||
| {% if osp_db_type == "postgresql" %} | ||||
| After=postgresql.service | ||||
| {% endif %} | ||||
| {% if osp_db_type == "mysql" %} | ||||
| After=mysql.service | ||||
| {% endif %} | ||||
| 
 | ||||
| [Service] | ||||
| User=http | ||||
| Group=http | ||||
| WorkingDirectory=/opt/osp/installs/osp-rtmp/ | ||||
| Environment="VIRTUAL_ENV=/opt/osp-venv" | ||||
| Environment="PATH=/opt/osp-venv/bin:/usr/local/bin:/usr/bin:/bin" | ||||
| ExecStart=/opt/osp-venv/bin/gunicorn app:app -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 --bind 127.0.0.1:{{ osp_worker_rtmp_port }} --reload --access-logfile /var/log/osp/access.log --error-logfile /var/log/osp/error.log | ||||
| Restart=on-failure | ||||
| RestartSec=5m | ||||
| 
 | ||||
| [Install] | ||||
| WantedBy=multi-user.target | ||||
		Loading…
	
		Reference in New Issue