Code Monkey home page Code Monkey logo

Comments (12)

Javernaut avatar Javernaut commented on August 23, 2024

Hello @mihir0109 ,

In the past I succeeded in executing ffmpeg binary in Android's terminal only (both via adb and from Android device itself). I haven't embedded it to an Android application.

The ffmpeg binary searches for *.so files by a relative path. All these *.so files should be accessible by ../lib/*.so relatively to ffmpeg binary. The ffmpeg binary doesn't expect the installation directory to be changed anyhow.

You can try placing all necessary files in assets rather than in jniLibs and move them all to device's storage. And then the binary should work properly.

from ffmpeg-android-maker.

Javernaut avatar Javernaut commented on August 23, 2024

@mihir0109 ,

Consider a 'portable' application. It has its file structure which shouldn't be messed. Only this way such an app can work if you just copy it into a target environment.

That is why you shouldn't change the structure of what FFmpeg building process prepared for you.

from ffmpeg-android-maker.

mihir0109 avatar mihir0109 commented on August 23, 2024

Hi @Javernaut ,

Thanks a lot for quick reply and suggestion.
Tried moving all .so files to data/ folder same like ffmpeg, but still getting same error.
CANNOT LINK EXECUTABLE "/data/user/0//files/ffmpeg": library "libavdevice.so" not found

from ffmpeg-android-maker.

Javernaut avatar Javernaut commented on August 23, 2024

@mihir0109 ,

Did you make the structure of files on the device like at the image below?

image

This way it should work properly.

from ffmpeg-android-maker.

mihir0109 avatar mihir0109 commented on August 23, 2024

I have put all these .so files in jniLibs->arm64-v8a->... and same for other 3 CPU architecture like x86 and x86_64.
And all files in assets -> arm64-v8a -> ... (all 7 .so files and ffmpeg and ffprobe binary)

then moving all these assets file to data/ folder.

static boolean copyBinaryFromAssetsToData(Context context, String fileNameFromAssets, String outputFileName) {

	// create files directory under /data/data/package name
	File filesDirectory = getFilesDirectory(context);
	
	InputStream is;
	try {
		is = context.getAssets().open(fileNameFromAssets);
		// copy ffmpeg file from assets to files dir
		final FileOutputStream os = new FileOutputStream(new File(filesDirectory, outputFileName));
		byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
		
		int n;
		while(EOF != (n = is.read(buffer))) {
			os.write(buffer, 0, n);
		}

        Util.close(os);
        Util.close(is);
		
		return true;
	} catch (IOException e) {
		Log.e("issue in coping binary from assets to data. ", e);
	}
    return false;
}

my cpu architecture is: arm64-v8a
copyBinaryFromAssetsToData(context, cpuArchNameFromAssets + File.separator + "libavcodec.so", "libavcodec.so");

Also loading library:

try {
System.loadLibrary("avutil");
System.loadLibrary("avcodec");
System.loadLibrary("avformat");
System.loadLibrary("swscale");
System.loadLibrary("swresample");
System.loadLibrary("avfilter");
System.loadLibrary("avdevice");
} catch (Exception e){
e.printStackTrace();
}

from ffmpeg-android-maker.

Javernaut avatar Javernaut commented on August 23, 2024

System.loadLibrary(xxx); isn't needed at all if you don't use the JNI bindings.

I would like to repeat again the thing regarding the file structure of binaries and shared libraries. They have to be in separate directories with specific names. See my screenshot above. You shouldn't place into a single directory - that just will not work.

from ffmpeg-android-maker.

mihir0109 avatar mihir0109 commented on August 23, 2024

Hello,

Yes, but as you said above, try moving .so files from assets folder to data/ folder same like ffmpeg binary.
The ffmpeg binary searches for *.so files by a relative path. All these .so files should be accessible by ../lib/.so

i tried earlier removing system.loadlibrary, but same issue.

from ffmpeg-android-maker.

mihir0109 avatar mihir0109 commented on August 23, 2024

Is there any way i can create ffmpeg itself with all necessary .so files.. i.e. using this scripe, i can generate ffmpeg with just 250 kb of binary.. can i get it which includes all .so files i.e. ffmpeg binary itself 20 mb, so other .so files dont required?

from ffmpeg-android-maker.

Javernaut avatar Javernaut commented on August 23, 2024

Not sure if this is possible. The ffmpeg binary is just a facade for a set of av** libraries. And there are other binaries that work with these shared libraries as well.

from ffmpeg-android-maker.

Javernaut avatar Javernaut commented on August 23, 2024

I've compiled the ffmpeg binary and tried everything myself. Indeed there is an issue just as you described: "CANNOT LINK EXECUTABLE "./ffmpeg": library "libavdevice.so" not found".

I'm sure the executable worked for me in the past, but I don't remember details. Perhaps my device was rooted and it impacted the thing somehow.

I'll investigate this issue further, but it isn't my priority for now.

from ffmpeg-android-maker.

mihir0109 avatar mihir0109 commented on August 23, 2024

Thanks a lot champ.. waiting for the updated one if can be fixed soon.

from ffmpeg-android-maker.

Javernaut avatar Javernaut commented on August 23, 2024

Transferred this issue to private Jira

from ffmpeg-android-maker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.