简体   繁体   English

Android Studio Java - 在没有 ffmpeg 的情况下将 3gp 文件转换为 wav

[英]Android Studio Java - Convert 3gp file to wav without ffmpeg

I'm writing an Android Studio project in Java that records audio, then sends it to a flask server to extract its musical notes.我正在 Java 中编写一个Java Android Studio项目来记录音频,然后将其发送到flask server以提取其音符。

Since I found MediaRecorder easier to use and more friendly than the other solutions, I use it to record the audio.由于我发现MediaRecorder比其他解决方案更易于使用且更友好,因此我使用它来录制音频。 However, it doesn't support wav format.但是,它不支持wav格式。 (The different output formats that are supported are MPEG_4 | WEBM | THREE_GPP | AAC_ADTS | AMR_NB | AMR_WB | MPEG_2_TS | OGG and I currently use 3gp (THREE_GPP)). (支持的不同 output 格式是MPEG_4 | WEBM | THREE_GPP | AAC_ADTS | AMR_NB | AMR_WB | MPEG_2_TS | OGG ,我目前使用3gp (THREE_GPP))。

Because my flask server accepts wav files only, my goal is to convert the recorded file (can be any of the supported formats above) to wav format.因为我的 flask 服务器只接受wav文件,所以我的目标是将录制的文件(可以是上述任何支持的格式)转换为wav格式。 I've already tried to use the ffmpeg library, as I found this solution on this website, but it didn't let me execute ffmpeg commands due to permission limits.我已经尝试使用ffmpeg库,因为我在这个网站上找到了这个解决方案,但由于权限限制,它没有让我执行ffmpeg commands

So my final question is, how can I convert the recorded audio file to wav format using Java and without executing any shell commands?所以我的最后一个问题是,如何在不执行任何 shell 命令的情况下使用Java将录制的音频文件转换为wav格式?

If there is a better way to accomplish my goals, such as fix the permission error I have had or any other solution, I would love to hear that as well.如果有更好的方法来实现我的目标,例如修复我的权限错误或任何其他解决方案,我也很想听听。

I've found an alternative to record wav files in android studio.我在 android 工作室中找到了录制wav文件的替代方法。

It is a class called WavAudioRecorder I found on github.这是我在 github 上找到的名为WavAudioRecorder的 class。

Credit: https://github.com/roman10/roman10-android-tutorial/blob/master/AndroidWaveRecorder/src/roman10/tutorial/androidwaverecorder/WavAudioRecorder.java信用: https://github.com/roman10/roman10-android-tutorial/blob/master/AndroidWaveRecorder/src/roman10/tutorial/androidwaverecorder/WavAudioRecorder.java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM