2023年8月

需要先安装ffmpeg

sudo apt install ffmpeg
def to_m3u8(input_file, output_file):
    import subprocess
    # checkout output_file parent dir exist,if not create it
    output_dir = os.path.dirname(output_file)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)

    cmd = f'ffmpeg -i {input_file} -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls {output_file}'
    subprocess.call(cmd, shell=True)

to_m3u8('input.mp4','output.m3u8')

server {
  listen 80;
  server_name luntan;
  root /var/www/html;
  index index.php index.html;

  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }

  location ~ \.php$ {
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }

  location ~ /\.ht {
    deny all;
  }
}