sayan801 / tuneSocially-VideoExtractionAndroidApp

2 stars 1 forks source link

Audio Extraction Issue using ffmpeg #1

Open sayan801 opened 10 years ago

sayan801 commented 10 years ago

I have been working on the android project; I am stuck! I am trying to use JAVE libraries to achieve audio extraction from videos, but it uses ffmpeg command and I am not able to figure out how I can get that command to work on my phone.

When I run the application, I get an error message - " java.io.IOException: Error running exec(). Command: [/data/data/com.example.videoextraction/cache/jae-1/ffmpeg, -i, sourcePath, -vn, -acodec, pcm_s16le, -f, wav, -y, destinationPath] Working Directory:null Environment: null ".

I spent all day trying out ways to get ffmpeg to work on android, I couldn't figure it out.

sayan801 commented 10 years ago

Android Media Documentation

http://developer.android.com/reference/android/media/MediaCodec.html

Jave Library URL

http://www.sauronsoftware.it/projects/jave/index.php

StackOverflow Url

sayan801 commented 10 years ago

I upgraded eclipse project to Android Studio and ran the code on my android nexus 4 device... i get following error..

10711422_10152691650403363_2137878721_n

sayan801 commented 10 years ago

I could reproduce the issue.. Here is the logs from my logcat..

09-22 19:01:03.660 7515-7515/com.example.videoextraction W/System.err﹕ java.io.IOException: Error running exec(). Command: [/bin/chmod, 755, /data/data/com.example.videoextraction/cache/jave-1/ffmpeg] Working Directory: null Environment: null 09-22 19:01:03.660 7515-7515/com.example.videoextraction W/System.err﹕ at java.lang.ProcessManager.exec(ProcessManager.java:211) 09-22 19:01:03.660 7515-7515/com.example.videoextraction W/System.err﹕ at java.lang.Runtime.exec(Runtime.java:173) 09-22 19:01:03.660 7515-7515/com.example.videoextraction W/System.err﹕ at java.lang.Runtime.exec(Runtime.java:128) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at it.sauronsoftware.jave.DefaultFFMPEGLocator.(DefaultFFMPEGLocator.java:85) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at it.sauronsoftware.jave.Encoder.(Encoder.java:111) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at com.example.videoextraction.MainActivity.onActivityResult(MainActivity.java:62) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at android.app.Activity.dispatchActivityResult(Activity.java:5423) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at android.app.ActivityThread.deliverResults(ActivityThread.java:3347) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at android.app.ActivityThread.handleSendResult(ActivityThread.java:3394) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at android.app.ActivityThread.access$1300(ActivityThread.java:135) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:102) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at android.os.Looper.loop(Looper.java:136) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5001) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at dalvik.system.NativeStart.main(Native Method) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ Caused by: java.io.IOException: No such file or directory 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at java.lang.ProcessManager.exec(Native Method) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ at java.lang.ProcessManager.exec(ProcessManager.java:209) 09-22 19:01:03.670 7515-7515/com.example.videoextraction W/System.err﹕ ... 18 more

sayan801 commented 10 years ago

In the Android Application, Its not able to find the ffmpeg executable..

Read this section from Jave Documentation ( http://www.sauronsoftware.it/projects/jave/manual.php#7 ).. It says jave library includes ffmpeg binary for windows and linux only.. for other you need to compile on your own..

Using an alternative ffmpeg executable
JAVE is not pure Java: it acts as a wrapper around an ffmpeg (http://ffmpeg.mplayerhq.hu/) executable. ffmpeg is an open source and free software project entirely written in C, so its executables cannot be easily ported from a machine to another. You need a pre-compiled version of ffmpeg in order to run JAVE on your target machine. The JAVE distribution includes two pre-compiled executables of ffmpeg: a Windows one and a Linux one, both compiled for i386/32 bit hardware achitectures. This should be enough in most cases. If it is not enough for your specific situation, you can still run JAVE, but you need to obtain a platform specific ffmpeg executable. Check the Internet for it. You can even build it by yourself getting the code (and the documentation to build it) on the official ffmpeg site. Once you have obtained a ffmpeg executable suitable for your needs, you have to hook it in the JAVE library. That's a plain operation. JAVE gives you an abstract class called it.sauronsoftware.jave.FFMPEGLocator. Extend it. All you have to do is to define the following method:

public java.lang.String getFFMPEGExecutablePath()
This method should return a file system based path to your custom ffmpeg executable.

Once your class is ready, suppose you have called it MyFFMPEGExecutableLocator, you have to create an alternate encoder that uses it instead of the default locator:

Encoder encoder = new Encoder(new MyFFMPEGExecutableLocator())
You can use the same procedure also to switch to other versions of ffmpeg, even if you are on a platform covered by the executables bundled in the JAVE distribution.

Anyway be careful and test ever your application: JAVE it's not guaranteed to work properly with custom ffmpeg executables different from the bundled ones.
sayan801 commented 10 years ago

you can use this executable of ffmpeg for android.. Read the following conversation..

http://stackoverflow.com/questions/4725773/ffmpeg-on-android

sayan801 commented 10 years ago

The project is to build an android app that achieves video to video/audio extraction. I just saw your comment on github, I was aware of that issue and have been trying to build ffmpeg for android, I tried out instructions mainly from these links :

http://www.roman10.net/how-to-build-ffmpeg-for-android/

http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/

https://enoent.fr/blog/2014/06/20/compile-ffmpeg-for-android/

http://stackoverflow.com/questions/23683518/how-to-compile-ffmpeg-2-2-2-on-windows-with-cygwin-and-android-ndk-r9c

Following those instructions did not exactly help- it did not work and I could not find online help for the error messages.

Is this approach complicating the project too much? Are there better ways of finishing it?

sayan801 commented 10 years ago

@aparnaSubr ffmpeg is the best option for video encoding and decoding.. There are several version of android port of ffmpeg.. Looks like following one is the best one..

https://github.com/guardianproject/android-ffmpeg

aparnaSubr commented 10 years ago

@sayan801 Thank you! I shall try that out :)

sayan801 commented 10 years ago

http://stackoverflow.com/questions/5337833/ffmpeg-on-android-undefined-references-to-libavcodec-functions-although-it-is http://www.quora.com/What-are-the-steps-for-integrating-FFMPEG-on-Android http://bambuser.com/opensource http://stackoverflow.com/questions/22864926/looking-for-ffmpeg-wrappers-for-android