I am working with ffmpeg to generate previews, but I get this error in the middle of the execution of my program:
“ffmpeg”: java.io.IOException: error=24, Too many open files
Does anybody know how to solve or how to avoid it??
I add the piece of code where I use ffmpeg:
for (int j = 0; j < temp.length; j++) {
if(j==2){
String preview = temp2[i] + temp[j] +".jpg";
Process p = Runtime.getRuntime().exec("ffmpeg -i anotados/" +temp2[i] + " -r 1 -ss 00:00:"+temp[j]+" -t 1 -s 158x116 imagenes/" + preview);
TextOut.write(preview+"\n");
}
}
Check your
ulimit -noutput to see how many open files processes spawned from that shell are allowed to have. Historical Unix systems had a limit of 20 files, but default on my Ubuntu desktop is 1024 open files.You may need to raise the number of open files you are allowed in the
/etc/security/limits.conffile. Or, you may need to modify your application to more aggressively close open files.Another possibility is a system-wide limit on number of files that may be open. I don’t know which modern systems would still have such limits in place, but a first place to look would be
sysctl -aoutput. (Well, maybe second place, after system documentation.)