嘿<>我需要修剪/剪切/编辑我的应用程序中的音频文件,我尝试使用ffmpeg但我不知道如何安装此库或如何使用它..所以,有人可以给我一个很好的指导如何使用ffmpeg 2.3与android ndk r10 for windows 7 64bit?或任何其他建议如何剪切mp3文件?
当我将ffmpeg库添加到我的项目时,我在控制台上收到了这个错误:
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] C:\Users\David\Workspace\RecordTheLast20Minutes\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] C:\Users\David\Workspace\RecordTheLast20Minutes\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] C:\Users\David\Workspace\RecordTheLast20Minutes\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
[2014-07-29 00:04:06 - RecordTheLast20Minutes] C:\Users\David\Workspace\RecordTheLast20Minutes\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
[2014-07-29 00:07:28 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:28 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:28 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:28 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:28 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:28 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:29 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:29 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:29 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:29 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:29 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:29 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:32 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:32 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:32 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:32 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:32 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:32 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:50 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:50 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:50 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:50 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:50 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:50 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:52 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:52 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:52 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:52 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:07:52 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:07:52 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:10:18 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:10:18 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:10:18 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:10:18 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:10:18 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:10:18 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:10:19 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:10:19 - RecordTheLast20Minutes] res\drawable-hdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:10:19 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:10:19 - RecordTheLast20Minutes] res\drawable-mdpi\ic_launcher.jpg:0: Originally defined here.
[2014-07-29 00:10:19 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.png:0: error: Resource entry ic_launcher is already defined.
[2014-07-29 00:10:19 - RecordTheLast20Minutes] res\drawable-xhdpi\ic_launcher.jpg:0: Originally defined here.
R.raw.music
或R.menu.actionbarmenu
R.layout.activity
等所有内容现在都是错误,R cannot be resolved to a variable
以及行ffmpeg -t 30 -i inputfile.mp3 -acodec copy outputfile.mp3
都是错误:
Multiple markers at this line
- Syntax error on token "copy", @ expected
- Syntax error on token "inputfile", delete this
token
- Syntax error on token(s), misplaced
construct(s)
- Syntax error on token(s), misplaced
construct(s)
- Syntax error on token "30", delete this token
Ty求助:)
答案 0 :(得分:1)
有许多开源Android ffmpeg项目,似乎最常用或讨论的项目是:
https://github.com/guardianproject/android-ffmpeg
这在Android平台上提供了ffmpeg,相关项目提供了Java包装器(使用Runtime.getRuntime()。exec方法,而不是我原先认为的JNI),允许您从常规Java Android应用程序中使用它: / p>
https://github.com/guardianproject/android-ffmpeg-java
上面的顶级项目包括构建说明和一些测试安装的示例。
使用ffmpeg二进制文件的Java Wrapper项目方法声明的一些示例如下所示。你可以在你下载的android-ffmpeg-java项目中看到'android-ffmpeg-java / src / org / ffmpeg / android / FfmpegController.java'文件中的完整代码:
public void extractAudio (Clip mdesc, String audioFormat, File audioOutPath, ShellCallback sc) throws IOException, InterruptedException
{ ...
public void concatAndTrimFilesMPEG (ArrayList<Clip> videos,Clip out, boolean preConvert, ShellCallback sc) throws Exception
{ ...
public Clip convertToMPEG (Clip mediaIn, String outPath, ShellCallback sc) throws Exception
{ ...
如果您看一下这些,您应该能够看到如何添加一个完全符合您要求的产品。实质上,这些方法使用Runtime.getRuntime()。exec函数调用cmd行ffmpeg和特定任务所需的参数。
根据以前在Android上使用Runtime.getRuntime()。exec的经验,需要注意的几件事情: