ffmpeg && nginx hls
1. ffmpeg 命令生成文件
a. ts ffmpeg -y -i mydemo.mp4 -vcodec copy -acodec copy -vbsf h264_mp4toannexb appdemos/mydemo.ts b. ts- > m3u8 ffmpeg -i appdemos/mydemo.ts -c copy -map 0 -f segment -segment_list appdemos/mydemo.m3u8 -segment_time 15 appdemos/mydemo%03d.ts 备注: 具体的可以参考ffmpeg 官方命令
通过nginx 基本配置 http { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-With; add_header Access-Control-Allow-Methods GET,POST,OPTIONS; server { listen 80; location / { # Serve HLS fragments types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root appdemos; expires -1; } } }
a. yum (使用nux-dexto) sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm sudo yum install ffmpeg ffmpeg-devel -y 备注:可能需要安装epel-release sudo yum install epel-release b. 源码编译 wget https://ffmpeg.org/releases/ffmpeg-3.4.2.tar.bz2 tar xjf ffmpeg-3.4.2.tar.bz2 ./configure make 备注:可能会有一些错误,按照提及即可
https://ffmpeg.org/ https://github.com/rongfengliang/ffmpeg-m3u8