Skip to content

Instantly share code, notes, and snippets.

@antonio-cg
Created February 29, 2020 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save antonio-cg/907191b75d251f2cd5a3cf476a07e8ee to your computer and use it in GitHub Desktop.
Save antonio-cg/907191b75d251f2cd5a3cf476a07e8ee to your computer and use it in GitHub Desktop.
installing flixac
Tested on ubuntu 18.04 x64
apt-get update
apt-get upgrade
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev unzip mc git zlib1g-dev
install nginx+rtmp+vod mudules
wget http://nginx.org/download/nginx-1.16.1.tar.gz
wget https://github.com/kaltura/nginx-vod-module/archive/master.zip -O nginx-vod-module.zip
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip -O nginx-rtmp-module.zip
unzip nginx-vod-module.zip
unzip nginx-rtmp-module.zip
tar -zxvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./configure --with-http_ssl_module --with-http_secure_link_module --add-module=../nginx-vod-module-master --add-module=../nginx-rtmp-module-master --with-file-aio --with-threads --with-http_auth_request_module
make
make install
Nginx auto start script
wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
chmod +x /etc/init.d/nginx
update-rc.d nginx defaults
service nginx start
-Configuring nginx
edit /usr/local/nginx/config/nginx.conf
#start config
user www-data;
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
error_log logs/debug.log debug;
events {
worker_connections 1024;
}
#rtmp end-point
rtmp {
server {
listen 1935;
chunk_size 4000;
a
pplication live{
live on;
# Turn on HLS
hls_nested on;
hls_path /var/hls; #path to store hls
hls on;
hls_fragment 3;
hls_playlist_length 60;
# disable consuming the stream from nginx as rtmp
#deny play all;
allow 127.0.0.1;
deny all;
}
}
}
http {
keepalive_timeout 65;
# vod caches
vod_metadata_cache metadata_cache 32m;
vod_response_cache response_cache 128m;
server {
root /var;
server_name 157.245.3.194;
index index.php index.html
# vod settings
#vod_mode mapped;
#vod_remote_upstream_location /proxy;
vod_last_modified 'Sun, 19 Nov 2000 08:52:00 GMT';
vod_last_modified_types *;
vod_max_upstream_headers_size 16k;
# vod caches
vod_mapping_cache mapping_cache 5m;
# gzip manifests
gzip on;
gzip_types application/vnd.apple.mpegurl;
# file handle caching / aio
open_file_cache max=1000 inactive=5m;
open_file_cache_valid 2m;
open_file_cache_min_uses 1;
open_file_cache_errors on;
aio on;
#configuration for vod-module
location /json {
access_log on;
error_log on;
log_not_found on;
try_files $uri $uri/
alias /json;
}
location /local/ {
alias /var/json/;
access_log on;
vod hls;
vod_mode mapped;
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
add_header Access-Control-Allow-Origin '*';
expires 1d;
}
location ~ /proxy/([^/]+)/(.*) {
internal;
proxy_pass $1://$2;
proxy_ssl_server_name on;
proxy_buffering off;
resolver 8.8.8.8;
}
location ~ ^/json/ {
vod hls;
vod_mode mapped;
vod_remote_upstream_location /proxy;
add_header Access-Control-Allow-Headers '*';
add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range';
add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS';
add_header Access-Control-Allow-Origin '*';
expires 100d;
}
#end vod-module configuration
#rtpm module for hls live-stream
location /hls {
root /var/;
add_header 'Cache-Control' 'no-cache';
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
}
}
}
#endconfig
installing ffmpeg
Adding PPA repository
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
-Building flixac-rest
apt install libmicrohttpd-dev automake libtool sqlite3 libsqlite3-dev
git clone https://github.com/antonio-cg/flixac-rest.git
cd flixac-rest
git clone https://github.com/etr/libhttpserver.git
cd libhttpserver
./bootstrap
mkdir build
cd build
../configure
make
make install
cd ..
cd ..
gcc -o httpbuild -I ./ *.cpp resources/* database/* -lhttpserver -lsqlite3 -std=gnu++14 -lstdc++
and run with ./httpbuild
if get erro ./httpbuild: error while loading shared libraries: libhttpserver.so.0: cannot open shared object file: No such file or directory
only run ldconfig
config file its flixac.ini
if all its ok server will run on the desired port and you can make petition with any rest client, example POSTMAN or with any rest client for any languaje
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment