简体   繁体   English

构建用于Android的FFmpeg以使用命令行参数

[英]Building FFmpeg for Android to use command line arguments

I am trying to build the FFmpeg library to use in my android app with the NDK. 我正在尝试构建FFmpeg库,以便在我的Android应用程序中使用NDK。 The reason for this is because I am using the native video capture feature in android because I really don't want to write my own video recorder. 原因是因为我在android中使用本机视频捕获功能,因为我真的不想编写自己的录像机。 However, the native video capture only allows for either high-quality encoding, or low quality encoding. 但是,本机视频捕获仅允许高质量编码或低质量编码。 I want something in between, and I believe that the solution is to use the FFmpeg library to re-encode the high quality video to be lighter. 我想要介于两者之间,我相信解决方案是使用FFmpeg库将高质量视频重新编码为更轻。

So far I have been able to build the FFmpeg library according to this guide: http://www.roman10.net/how-to-build-ffmpeg-for-android/ and which a few tweaks I have been able to get it to work. 到目前为止,我已经能够根据本指南构建FFmpeg库: http//www.roman10.net/how-to-build-ffmpeg-for-android/以及我能够获得的一些调整上班。

However, everything that I've found seems to be about writing your own encoder, which seems like overkill to me. 但是,我发现的所有内容似乎都是关于编写自己的编码器,这对我来说似乎有些过分。 All that I really want to do is send a string in command line format to the main() function of FFmpeg and re-encode my video. 我真正想做的就是将命令行格式的字符串发送到FFmpeg的main()函数并重新编码我的视频。 However, I can't seem to figure out how I build FFmpeg to give me access to the main method. 但是,我似乎无法弄清楚我是如何构建FFmpeg来让我访问main方法的。 I found this post: Compile ffmpeg.c and call its main() via JNI which links to a project doing what I want more of less, but for the life of me I cannot figure out what is going on. 我找到了这篇文章: 编译ffmpeg.c并通过JNI调用它的main(),它连接到一个项目,做我想要的更多,但对于我的生活,我无法弄清楚发生了什么。 It also seems like he is compiling more than I want, and I would really like to keep my application as light weight as possible. 看起来他的编译比我想要的还多,我真的希望尽可能保持我的应用程序的重量。

Some additional direction would be extremely helpful. 一些额外的方向将非常有帮助。 Thank you. 谢谢。

In Android NDK there is no main() in your application in the typical sense, so you are unable to do what you want to directly. 在Android NDK中,典型意义上的应用程序中没有main(),因此您无法直接执行所需操作。 However, you can still call the main() of FFmpeg yourself and provide all necessary parameters to it. 但是,您仍然可以自己调用FFmpeg的main()并为其提供所有必要的参数。 Here are 2 possibilities to get the parameters: 以下是获取参数的两种可能性:

  1. Android Activity receives an Intent after creation. Android Activity在创建后收到Intent。 You can pass the parameters through the intent while starting your activity and then extract it like this: 您可以在开始活动时通过intent传递参数,然后像这样提取它:

     Intent CommandLine = this.getIntent(); Uri uri = CommandLine.getData(); 
  2. You can read parameters from file you create somewhere on a SD-card and pass the to FFmpeg. 您可以从SD卡上创建的文件中读取参数,并将其传递给FFmpeg。

The second answerer seems to have your answer . 第二个回答者似乎有你的答案。 Please refer to this link . 请参阅此链接。 Can FFmpeg be used as a library, instead of a standalone program? FFmpeg可以用作库而不是独立程序吗?

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

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