Javacv: normalize_path - invalid input: "lib/", the input path should be absolute

Created on 22 Jan 2019  路  18Comments  路  Source: bytedeco/javacv

val fffr = FFmpegFrameRecorder(Environment.getExternalStorageDirectory().absolutePath + File.separator + "test.mp4",256,256)
        try {
            fffr.videoCodec = avcodec.AV_CODEC_ID_MPEG4
            fffr.format = "mp4"
            fffr.frameRate = 30.0
            fffr.pixelFormat = avutil.AV_PIX_FMT_YUV420P
            fffr.videoBitrate = 1200
            fffr.start()

            for (i in 0..4) {
                activity_record_layout.isDrawingCacheEnabled = true
                val b = Bitmap.createBitmap(activity_record_layout.drawingCache)
                //val frame =viewToFrame(activity_record_layout)
                val frame = AndroidFrameConverter().convert(b)
                recorder.record(frame)
            }

            fffr.stop()
        }
        catch (e: Exception){
            e.printStackTrace()
        }

I have above simple function to record view using FFmpegRecorder. However I have following issue when I'm running the code:

E/linker: normalize_path - invalid input: "lib/", the input path should be absolute
W/linker: Warning: unable to normalize "lib/"
W/System.err: org.bytedeco.javacv.FrameRecorder$Exception: avio_open2 error() error -13: Could not open 'null'

I have searched issues with error -13 but didn't find any useful information. Please help thanks!

here's my grade dependencies for java cv:

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation group: 'org.bytedeco', name: 'javacv', version: '1.4.4'
    implementation 'org.bytedeco.javacpp-presets:opencv:4.0.1-1.4.4:android-arm'
    implementation 'org.bytedeco.javacpp-presets:opencv:4.0.1-1.4.4:android-x86'
    implementation 'org.bytedeco.javacpp-presets:ffmpeg:4.1-1.4.4:android-arm'
    implementation 'org.bytedeco.javacpp-presets:ffmpeg:4.1-1.4.4:android-x86'
question

All 18 comments

Since this isn't a problem, let's mark this as "enhancement". Please consider making a contribution :)

If you're wondering why Environment.getExternalStorageDirectory() returns null, that's not an issue with JavaCV, it's probably a problem with the permissions of your application.

Thank you @saudet. You are right, the issue was caused by the permissions issue. If anyone has the same issue, please double check you have the code to request correct permissions. I believe starting from Android 6.0 (API level 23), you need to have both manifest and request code in order to get permission granted.

https://developer.android.com/training/permissions/requesting

Which Android permissions exactly do I need to set for this error "normalize_path - invalid input: "lib/", the input path should be absolute" not to be present?

@Maja755 That's probably just a warning that we can ignore.

The only thing that I can see that could do that is the rpath given in these properties:
https://github.com/bytedeco/javacpp/tree/master/src/main/resources/org/bytedeco/javacpp/properties
I believe it used to be required a long long time ago, but I think we can remove it now...
@Maja755 Please give it a try! Thanks

@saudet Thank you for your previous answer about ignoring the warning. Though I don't understand your last reply...
But in this context, when ignoring the above mentioned warning, I get the following errors, which I am not sure have anything to do with the warning:

2019-10-03 18:24:14.658 1400-1668/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
2019-10-03 18:24:14.997 1400-1434/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
2019-10-03 18:24:15.609 1603-1620/? E/BluetoothAdapter: Bluetooth binder is null
2019-10-03 18:24:15.623 1603-1620/? E/KernelUidCpuFreqTimeReader: Failed to read /proc/uid_time_in_state: java.io.FileNotFoundException: /proc/uid_time_in_state (No such file or directory)
2019-10-03 18:24:15.623 1603-1620/? E/KernelCpuSpeedReader: Failed to read cpu-freq: /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state (No such file or directory)
2019-10-03 18:24:15.702 1603-1620/? E/BatteryExternalStatsWorker: modem info is invalid: ModemActivityInfo{ mTimestamp=0 mSleepTimeMs=0 mIdleTimeMs=0 mTxTimeMs[]=[0, 0, 0, 0, 0] mRxTimeMs=0 mEnergyUsed=0}

What would you say about these errors?

@Maja755 Those don't look related, no.

So what is the exactly permission?My device is on Android O or later.I just write this:
String str = Loader.load(ffmpeg.class);
Now the str is null.
and then I got this :
E/linker: normalize_path - invalid input: "lib/", the input path should be absolute W/linker: Warning: unable to normalize "lib/" (ignoring)
I've already require the WRITE & READ EXTERNAL STORAGE permissions.But this problem occurs.

@qq12cvhj That's just a warning, not an error. The error is some other message in the log.

I tried 'org.bytedeco:ffmpeg-platform:4.2.2-1.5.3' few day ago
For some reason Loader.load(ffmpeg.class); return null (same with @qq12cvhj )
avcodec other binding in org.bytedeco.ffmpeg.global.** still work
and the apk looking good though
image

I'm using this library on Android
Could you please check @saudet
Thanks!

@nlgtuankiet That's been fixed in 1.5.4-SNAPSHOT, see issue #1410.
Please give it a try with the snapshots: http://bytedeco.org/builds/

thank @saudet
I tried 1.5.4-SNAPSHOT
Good new is Loader.load(ffmpeg::class.java) working well, but I got permission denied when trying to execute the command ffmpeg (both alone with no params and with params) using the ProcessBuilder (from the doc)
Any idea?

2020-06-13 15:56:08.748 1568-3248/com.nlgtuankiet.ffmpeg1 E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
    Process: com.nlgtuankiet.ffmpeg1, PID: 1568
    java.lang.Error: java.io.IOException: Cannot run program "/data/data/com.nlgtuankiet.ffmpeg1/cache/.javacpp-root/cache/base.apk/lib/arm64-v8a/ffmpeg": error=13, Permission denied
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1173)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:929)
     Caused by: java.io.IOException: Cannot run program "/data/data/com.nlgtuankiet.ffmpeg1/cache/.javacpp-root/cache/base.apk/lib/arm64-v8a/ffmpeg": error=13, Permission denied
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
        at com.nlgtuankiet.ffmpeg1.MainActivity.exeCommand(MainActivity.kt:65)
        at com.nlgtuankiet.ffmpeg1.MainActivity.access$exeCommand(MainActivity.kt:24)
        at com.nlgtuankiet.ffmpeg1.MainActivity$execute$1.run(MainActivity.kt:48)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)聽
        at java.lang.Thread.run(Thread.java:929)聽
     Caused by: java.io.IOException: error=13, Permission denied
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
        at java.lang.ProcessImpl.start(ProcessImpl.java:141)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        at com.nlgtuankiet.ffmpeg1.MainActivity.exeCommand(MainActivity.kt:65)聽
        at com.nlgtuankiet.ffmpeg1.MainActivity.access$exeCommand(MainActivity.kt:24)聽
        at com.nlgtuankiet.ffmpeg1.MainActivity$execute$1.run(MainActivity.kt:48)聽
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)聽
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)聽
        at java.lang.Thread.run(Thread.java:929)聽

You've probably forgotten to give execute permission to your app.

@saudet thank man, it work!

For those who are using this library on android, try this:

val ffmpeg = Loader.load(ffmpeg::class.java)
require(File(ffmpeg).setExecutable(true))
repositories {
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
implementation 'org.bytedeco:ffmpeg-platform:4.2.3-1.5.4-SNAPSHOT'

File.setExecutable(true) already gets called before returning it, so something else is causing problems here: https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/Loader.java#L1262

BTW, it appears that Android API 29+ doesn't support executing files like that anymore, so we might have to use API 28 or lower until they figure out another way to let us do that again.

yup, my compileSdkVersion is 29 but I set targetSdkVersion to 28. As @saudet mention targetSdkVersion 29 will not work and you will get an exception:

     Caused by: java.io.IOException: error=13, Permission denied
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
        at java.lang.ProcessImpl.start(ProcessImpl.java:141)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        at org.zeroturnaround.exec.ProcessExecutor.invokeStart(ProcessExecutor.java:997)聽
        at org.zeroturnaround.exec.ProcessExecutor.startInternal(ProcessExecutor.java:970)聽
        at org.zeroturnaround.exec.ProcessExecutor.execute(ProcessExecutor.java:906)聽

I have since an open that put ffmpeg executable file in the assets folder, at run time they copy it into the app folder ann execute the file from there. I haven't tried it yet but targetSdkVersion 28 seems just fine for me now

Edit: nope you still got permission denied

@nlgtuankiet Try an even older version of the SDK. It works fine for me when targeting Android 7.0, see issue #1410.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bahramudin picture Bahramudin  路  3Comments

kongqw picture kongqw  路  4Comments

RaGreen picture RaGreen  路  4Comments

chrisliu12345 picture chrisliu12345  路  4Comments

cansik picture cansik  路  4Comments