Reposted from superuser: https://superuser.com/questions/1340574/ffmpeg-copy-hls-high-cpu-usage
I have a set of batch scripts (Windows 10) to create an "instant replay" for some (11) HLS streams using FFMPEG. When everything is working each instance uses less than 1% CPU. The problem I have is that FFMPEG regularly hangs and does not continue looping. When this happens, the instance jumps to 10-15% CPU usage.
The first time I had this problem, I updated my graphics card drivers and FFMPEG version and that worked for a while but the problem came back. I assumed that it was the graphics card going bad. I now have a brand new computer (Precision 7520 with Xeon E3-1535M v6, Quadro M2200, and 32GB ECC RAM) and the problem persists. I have no idea what the cause is. I have tried updating FFMPEG again to no avail.
If anybody has a fix that would be the best; however, if you know a way to monitor the processor usage and automatically kill ffmpeg when it spikes for more than 10s that would be an acceptable solution.
The recorder script is as follows:
::SegLength is normally 30 to 60 seconds
mkdir "%BasePath%\%Event%\%CamName%\" for /f %%i in ('yt-dl PATH_TO_master.m3u8 -f best --get-url') do set url="%%i"
:beg Set "FileName=%CamName%.%TIME::=-%.mp4" ffmpeg -n -i %url% -t %SegLength% -c:v copy -c:a copy -f mp4 "%BasePath%\%Event%\%CamName%\%FileName%" goto :beg