Guest User

Untitled

a guest
Apr 5th, 2020
1,196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 1.40 KB | None | 0 0
  1. server {
  2.         listen 8080 default_server;
  3.         listen [::]:8080 default_server;
  4.  
  5.         root /home/YOURNAMEHERE/www/html;
  6.  
  7.         index index.html index.htm index.nginx-debian.html;
  8.  
  9.         server_name _;
  10.  
  11.         location / {
  12.                 # First attempt to serve request as file, then
  13.                 # as directory, then fall back to displaying a 404.
  14.                 try_files $uri $uri/ =404;
  15.         }
  16.  
  17.         location ~ /transcode {
  18.                content_by_lua_block {
  19.                    local source_url = "http://IP_OF_HDHOMERUN:5004/auto/" .. ngx.var.arg_channel
  20.                    local port = tostring((ngx.crc32_short(ngx.var.arg_channel) % 1024) + 8192)
  21.                    local cmd = "/usr/bin/nohup /usr/bin/ffmpeg -loglevel fatal -analyzeduration 3000000 -fflags +igndts -ignore_unknown -strict experimental -threads 0 -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 -i " .. source_url .. " -f mpegts -c:v:0 mpeg2_vaapi -c:a:0 copy -y -listen 1 http://" .. ngx.var.server_addr .. ":" .. port .. " < /dev/null &"
  22.                    os.execute(cmd)
  23.                    ngx.sleep(5)
  24.                    ngx.header["X-cmd"] = cmd
  25.                    ngx.redirect("http://" .. ngx.var.server_addr .. ":" .. port)
  26.                }
  27.         }
  28.  
  29.         location ~ /auto {
  30.                 rewrite ^/auto/(.*)$ /transcode?channel=$1 last;
  31.         }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment