Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pydub: Couldn't find ffmpeg or avconv #457

Closed
avijoy-chakma opened this issue Mar 4, 2021 · 1 comment
Closed

pydub: Couldn't find ffmpeg or avconv #457

avijoy-chakma opened this issue Mar 4, 2021 · 1 comment

Comments

@avijoy-chakma
Copy link

Chaquopy version

In the application gradle file -

dependencies {
classpath "com.android.tools.build:gradle:4.1.0"
classpath "com.chaquo.python:gradle:9.1.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

Devices or emulators where the issue happens

Device: Pixel 3
Emulator: Pixel_3A_API_30_x86
The issue happens in both emulator and device

Relevant parts of your code

From JAVA file

Python py = Python.getInstance();
final PyObject pyobj = py.getModule("wavConversion");
PyObject obj = pyobj.callAttr("convert", sourceFile, convertFile);

Python code snippet for conversion -

from pydub import AudioSegment
def convert(source, target):
sound = AudioSegment.from_file(source)
sound.export(target, format="wav")

The stack trace -

2021-03-03 20:01:20.585 3897-3897/com.example.myapplication W/e.myapplication: type=1400 audit(0.0:33272): avc: granted { execute } for path="/data/data/com.example.myapplication/files/chaquopy/AssetFinder/stdlib-arm64-v8a/audioop.so" dev="dm-8" ino=603152 scontext=u:r:untrusted_app:s0:c59,c257,c512,c768 tcontext=u:object_r:app_data_file:s0:c59,c257,c512,c768 tclass=file app=com.example.myapplication
2021-03-03 20:01:20.605 3897-3897/com.example.myapplication W/python.stderr: /data/user/0/com.example.myapplication/files/chaquopy/AssetFinder/requirements/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
2021-03-03 20:01:20.630 3897-3897/com.example.myapplication W/python.stderr: /data/user/0/com.example.myapplication/files/chaquopy/AssetFinder/requirements/pydub/utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
2021-03-03 20:01:20.673 3897-3897/com.example.myapplication W/System.err: com.chaquo.python.PyException: FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe'
2021-03-03 20:01:20.673 3897-3897/com.example.myapplication W/System.err: at .subprocess._execute_child(subprocess.py:1702)
2021-03-03 20:01:20.673 3897-3897/com.example.myapplication W/System.err: at .subprocess.init(subprocess.py:854)
2021-03-03 20:01:20.673 3897-3897/com.example.myapplication W/System.err: at .pydub.utils.mediainfo_json(utils.py:274)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at .pydub.audio_segment.from_file(audio_segment.py:685)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at .wavConversion.convert(wavConversion.py:33)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at .chaquopy_java.call(chaquopy_java.pyx:380)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at .chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrowsNative(chaquopy_java.pyx:352)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at com.chaquo.python.PyObject.callAttrThrowsNative(Native Method)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at com.chaquo.python.PyObject.callAttrThrows(PyObject.java:232)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at com.chaquo.python.PyObject.callAttr(PyObject.java:221)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at com.example.myapplication.AudioRecorder.stopRecording(AudioRecorder.java:182)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at com.example.myapplication.AudioRecordService.onDestroy(AudioRecordService.java:75)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at android.app.ActivityThread.handleStopService(ActivityThread.java:4349)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at android.app.ActivityThread.access$1900(ActivityThread.java:237)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1956)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at android.os.Looper.loop(Looper.java:223)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7660)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
2021-03-03 20:01:20.674 3897-3897/com.example.myapplication W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Describe your issue

I'm trying to use Chaquopy in Android to convert a 3gpp audio file into a WAV format. The 3gpp files are recorded using "android.media.MediaRecorder" and stored in the external location (Download folder and permission are granted for read+write operation). I'm using Ubuntu 18.04 and I've already installed "ffmpeg, PyDub" library. The code snippet works fine in Jupyter Notebook but troubles when integrated into the Android environment. There are a few similar questions but not properly explained/ the solutions are not working. Any help/solution? Thank you.

@mhsmith mhsmith changed the title RuntimeWarning: Couldn't find ffmpeg or avconv pydub: Couldn't find ffmpeg or avconv Mar 4, 2021
@mhsmith
Copy link
Member

mhsmith commented Mar 4, 2021

Chaquopy doesn't provide an ffmpeg executable, so I think the best approach is:

  • Convert the audio to a WAV file using mobile-ffmpeg (see the examples linked from FFmpeg #143).
  • If you want to do any further processing, load the WAV file using pydub.

@mhsmith mhsmith closed this as completed Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants