There is FFmpeg Static (binary) available for Android and we can stop/cancel some FFmpeg execution (command) while it's doing something https://github.com/WritingMinds/ffmpeg-android-java/issues/33
But I want to use FFmpeg shared libraries and JNI, I found next library https://github.com/IljaKosynkin/FFmpeg-Development-Kit (it works ok)
But there is no option to stop execution of FFmpeg command (or killing the process)
We use Java native run method there to start execute some command:
Java:
https://github.com/IljaKosynkin/FFmpeg-Development-Kit/blob/master/JNI/app/src/main/java/com/example/ilja/jni/VideoKit.java#L57
and then in C we call FFmpeg's main method:
C:
https://github.com/IljaKosynkin/FFmpeg-Development-Kit/blob/master/JNI/app/jni/videokit.c#L41
How can I stop/cancel some FFmpeg executing after I called Java run and C main methods?
the solution is to edit ffmmpeg class (add some variables to check if it should execute farther or not)
Related
Whick gradle task is the fastest to check whether the code passes compilation without any syntax error on Android project
Based on the output of the command
./gradlew tasks --all
executed in a directory containing a small Android project, I'd suggest that your best bet is either the command
./gradlew compileReleaseSources
or the command
./gradlew compileReleaseJava
Here's the full list of tasks that compileReleaseSources depends on for my project (might vary slightly for your own):
app:compileReleaseSources
app:checkReleaseManifest
app:compileReleaseAidl
app:compileReleaseJava
app:compileReleaseNdk
app:compileReleaseRenderscript
app:generateReleaseAssets
app:generateReleaseBuildConfig
app:generateReleaseResValues
app:generateReleaseResources
app:generateReleaseSources
app:mergeReleaseAssets
app:mergeReleaseResources
app:preBuild
app:preDebugBuild
app:preReleaseBuild
app:prepareComAndroidSupportAppcompatV72210Library - Prepare com.android.support:appcompat-v7:22.1.0
app:prepareComAndroidSupportSupportV42210Library - Prepare com.android.support:support-v4:22.1.0
app:prepareReleaseDependencies
app:processReleaseManifest
app:processReleaseResources
Note that this includes the Java compilation step, as well as the compilation of other code sources and various resource processing. Depending on your exact needs, calling compileReleaseJava instead of compileReleaseSources may be enough and will be faster. (Unfortunately, I don't know of a way to view Gradle task dependencies in a tree-like structure, so it's not clear to me exactly how much faster the compileReleaseJava task would be).
If you also want to check that test code compiles, you'd need to add an analogous command: e.g. compileDebugTestSources.
I am writing a small Android program that can check how many files contains a certain string without reading completely their contents
Therefore, I've found a good way to do it is using grep -q command. Because of executing the command doesn't output but a exit code (0 : match, 1 : not match)
However I have no idea that how to get the exit code after executing the command completed by C language in JNI.
I want to start a custom program in the init process. I compiled this program statically that run fine from my booted up android stock ROM.
From the android init.rc docs I read that the exec command is what I need.
BTW all I can see in dmesg is that my program exit with code -1 (I can't return that).
init.rc snippet:
on post-fs-data
write /dev/kmsg "launching test"
exec /data/test
All I see in dmesg is this:
<4>[ 6.336816] launching test
<6>[ 6.336902] init: command 'write' r=0
<6>[ 6.337115] init: command 'exec' r=-1
Here you are the executable source code: http://pastebin.com/Hym1APWx
UPDATE
I tried to statically compile and run this program:
int main(){return 0; }
But the result is always command 'exec' r=-1. Maybe user uselen are right, maybe I cannot run executables from /data in the early-boot phase.
As christian said, it looks like exec isn't even implemented. I'm beginning to think that a lot of features documented for init.rc aren't implemented. Here's a way you can get your program to launch however.
Instead of running this as an "exec" command, set this up as a service instead.
In your init.rc, or another file included by it:
service my_service /data/test
class main
oneshot
If it's in class main, and not disabled, it should run after /data is mounted.
I had the same issue today. In my case the solution was simple: The exec function wasn't implemented yet and contained just a return -1. You should take a look at builtin.c and search for do_exec(). This code is executed when init.rc contains an exec statement.
I load the Android example NotePad and added one standard JavaThread, called TEST1.
When I look into the Threads of my NotePadApp (which does not execute native c/c++ code), I can observe the following:
My question is:
Does the Status "native" really mean that there's native c/c++
executing in these threads or does native has no connection to c/c++
code and the Android NDK / JNI stuff?
Would my Thread TEST1 also get status native if I load and execute c/c++ code?
I'm trying to run a JAR file I built using the following command line (from adb shell):
dalvikvm -cp /sdcard/MyJar.jar MyJar.main.Main
My Main class has only a single method main:
public static void main(String[] args)
{
// Connect to local db
SQLiteDatabase db = SQLiteDatabase.openDatabase(DB_PATH, null, SQLiteDatabase.OPEN_READWRITE);
}
When I run the command line it looks like the main function runs but then I get the following exception:
java.lang.UnsatisfiedLinkError: native_get_int
at android.os.SystemProperties.native_get_int(Native Method)
at android.os.SystemProperties.getInt(SystemProperties.java:74)
at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1846)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
at MyJar.main.Main.main(Main.java:146)
at dalvik.system.NativeStart.main(Native Method)
My guess is that I need to load some kind of library to resolve this link error but I have no clue which library it is (this seems like a basic thing that probably should have been loaded by dalvikvm...).
Any ideas ?
Try running app_process instead of dalvikvm.
Vogar makes this kind of thing very easy. Check out the latest vogar from their SVN page, build it with ant, and then run this on your Linux desktop
~/Projects/vogar/bin/vogar --mode app_process ~/myapp/src/com/me/Main.java
Vogar will build your .java, create a .dex file, use adb to copy that to your device, and then execute VM on the device for you. We use it to develop Dalvik.