![如何减少 mpd 到 m3u8 重新流式传输的 CPU 负载](https://linux22.com/image/1620056/%E5%A6%82%E4%BD%95%E5%87%8F%E5%B0%91%20mpd%20%E5%88%B0%20m3u8%20%E9%87%8D%E6%96%B0%E6%B5%81%E5%BC%8F%E4%BC%A0%E8%BE%93%E7%9A%84%20CPU%20%E8%B4%9F%E8%BD%BD.png)
我在重播时 CPU 负载达到 100%。有什么解决方案可以减少它吗?
[program:channel]
autorestart=true
command=/usr/local/ffmpeg/bin/ffmpeg -re -hide_banner -headers 'Referer: https://example.com/' -i https://stream.webm.mpd -c:v libx264 -preset ultrafast -tune zerolatency -c:a aac -b:a 128k -f hls -hls_time 4 -hls_flags append_list+delete_segments -hls_list_size 6 -hls_segment_filename '/etc/nginx/hls/channel/file%%03d.ts' /etc/nginx/hls/channel/playlist.m3u8
linux
答案1
你可以尝试流复制模式。
正常ffmpeg
命令:
ffmpeg -re -headers 'Referer: https://example.com/' -i https://stream.webm.mpd -c copy -f hls -hls_time 4 -hls_flags append_list+delete_segments -hls_list_size 6 -hls_segment_filename '/etc/nginx/hls/channel/file%03d.ts' /etc/nginx/hls/channel/playlist.m3u8
针对主管进行了修改:
[program:channel]
autorestart=true
command=/usr/local/ffmpeg/bin/ffmpeg -re -headers 'Referer: https://example.com/' -i https://stream.webm.mpd -c copy -f hls -hls_time 4 -hls_flags append_list+delete_segments -hls_list_size 6 -hls_segment_filename '/etc/nginx/hls/channel/file%%03d.ts' /etc/nginx/hls/channel/playlist.m3u8
如果流复制不是一个选项,而您必须重新编码,那么手动使用该-threads
选项或者使用 Linuxnice
命令,或者任何与您当前未知的操作系统等效的命令,但性能可能会受到影响。