我在重播时 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
命令,或者任何与您当前未知的操作系统等效的命令,但性能可能会受到影响。