Too many open files : E Parcel : dup() failed in Parcel::read, i is 1, fds[i] is -1, fd_count is 2, error:Too many open files
Solution: Linux application processes are generally allowed to enable 1024 file descriptors (FD), which can be easily exceeded if resources are occupied and forgotten to be released, such as opening anonymous shared memory or opendir not calling Closedir in JNI
Check application PID. 2. Ls -a -l /proc/<pid>/fd Check abnormal file descriptors and handle them accordinglyCopy the code
FFMPEG YUV video extraction frame
$ ffmpeg -y -s 1088x1920 -i /Users/loki/Desktop/tmp_live1_0.yuv .. /test.jpgCopy the code
FFMPEG video extraction frame
$ ffmpeg -i vid.avi -r 20 mmm%5d.png
Copy the code
Thread tied nuclear
#define __USE_GNU
#include<sched.h>
static int getCores(a) {
return sysconf(_SC_NPROCESSORS_CONF);
}
jint JNI_bindToCpu(JNIEnv *env,jclass type, jint cpu) {
int cores = getCores(a);if(cpu>=cores){
return 2 -;
}
cpu_set_t mask;
CPU_ZERO(&mask);
CPU_SET(cpu,&mask);
if(sched_setaffinity(0.sizeof(mask), &mask)==- 1) {return - 1;
}
return 0;
}
Copy the code
$ adb shell ps -t -p -c
Copy the code
It can be seen that both the Test thread and the JNI internal thread are running on the 1 core
Android Studio NDK issues
NDK not configured. Download it with SDK manager. Preferred NDK version is ‘20.0.5594570’.log: /Users/loki/Desktop/work/proj_out/PassengerMock/moc2/.cxx/ndk_locator_record.json
Configure the ndk.dir in the project local.propertiesCopy the code
Failed resolution of: Landroidx/localbroadcastmanager/content/LocalBroadcastManager;
Implementation ‘Androidx. Legacy :legacy-support-v4:1.0.0’
Use the command to re-sign the system
$ java -Djava.library.path=. -jar signapk.jar platform.x509.pem platfrom.pk8 app.apk out.apk
Copy the code