参考文档:https://lists.ffmpeg.org/pipermail/ffmpeg-user/2013-November/018558.html
1、安装编译ffmpeg并支持x264,gpl扩展
--enable-libx264 --enable-gpl
2、执行ffmpeg命令转换流
ffmpeg -v verbose -i rtmp://<host>:<port>/<stream> -c:v libx264 -c:a aac -ac 1 -strict -2 -crf 18 -profile:v baseline -maxrate 400k -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -start_number 1 <pathToFolderYouWantTo>/<streamName>.m3u8
例如:
/usr/bin/ffmpeg -v verbose -i rtsp://admin:a12345@192.168.1.1:554/h265/ch1/main/av_stream -c:v libx264 -c:a aac -ac 1 -strict -2 -crf 18 -profile:v baseline -s 640x360 -maxrate 400k -bufsize 1835k -pix_fmt yuv420p -flags -global_header -hls_time 10 -hls_list_size 6 -hls_wrap 10 -start_number 1 /usr/share/nginx/html/live/live.m3u8