gpt4 book ai didi

android - 从java代码调用为Android编译的FFmpeg可执行文件的简单方法是什么?

转载 作者:行者123 更新时间:2023-12-04 23:04:29 27 4
gpt4 key购买 nike

我已经为 Android 编译了 FFmpeg,以满足我在编解码器、多路复用器等方面的需求。
现在我有一个可执行文件,据我了解,它应该放在我的项目目录中 <project-root>/external/<arbitrary-folder-name>/data/data/<my-app-package-name>/app_opt 下。 .我里面有什么app_opt现在是:

    .
├── bin
│ └── ffmpeg
├── include
│ ├── libavcodec
│ │ ├── avcodec.h
│ │ ├── avfft.h
│ │ ├── dxva2.h
│ │ ├── vaapi.h
│ │ ├── vda.h
│ │ ├── vdpau.h
│ │ ├── version.h
│ │ └── xvmc.h
│ ├── libavdevice
│ │ └── avdevice.h
│ ├── libavfilter
│ │ ├── asrc_abuffer.h
│ │ ├── avcodec.h
│ │ ├── avfiltergraph.h
│ │ ├── avfilter.h
│ │ ├── buffersink.h
│ │ ├── buffersrc.h
│ │ ├── version.h
│ │ └── vsrc_buffer.h
│ ├── libavformat
│ │ ├── avformat.h
│ │ ├── avio.h
│ │ └── version.h
│ ├── libavutil
│ │ ├── adler32.h
│ │ ├── aes.h
│ │ ├── attributes.h
│ │ ├── audioconvert.h
│ │ ├── audio_fifo.h
│ │ ├── avassert.h
│ │ ├── avconfig.h
│ │ ├── avstring.h
│ │ ├── avutil.h
│ │ ├── base64.h
│ │ ├── bprint.h
│ │ ├── bswap.h
│ │ ├── common.h
│ │ ├── cpu.h
│ │ ├── crc.h
│ │ ├── dict.h
│ │ ├── error.h
│ │ ├── eval.h
│ │ ├── fifo.h
│ │ ├── file.h
│ │ ├── imgutils.h
│ │ ├── intfloat.h
│ │ ├── intfloat_readwrite.h
│ │ ├── intreadwrite.h
│ │ ├── lfg.h
│ │ ├── log.h
│ │ ├── lzo.h
│ │ ├── mathematics.h
│ │ ├── md5.h
│ │ ├── mem.h
│ │ ├── opt.h
│ │ ├── parseutils.h
│ │ ├── pixdesc.h
│ │ ├── pixfmt.h
│ │ ├── random_seed.h
│ │ ├── rational.h
│ │ ├── samplefmt.h
│ │ ├── sha.h
│ │ ├── timecode.h
│ │ └── timestamp.h
│ ├── libpostproc
│ │ └── postprocess.h
│ ├── libswresample
│ │ └── swresample.h
│ └── libswscale
│ └── swscale.h
├── lib
│ ├── libavcodec.a
│ ├── libavdevice.a
│ ├── libavfilter.a
│ ├── libavformat.a
│ ├── libavutil.a
│ ├── libpostproc.a
│ ├── libswresample.a
│ ├── libswscale.a
│ └── pkgconfig
│ ├── libavcodec.pc
│ ├── libavdevice.pc
│ ├── libavfilter.pc
│ ├── libavformat.pc
│ ├── libavutil.pc
│ ├── libpostproc.pc
│ ├── libswresample.pc
│ └── libswscale.pc
└── share
└── ffmpeg
├── examples
│ ├── decoding_encoding.c
│ ├── filtering_audio.c
│ ├── filtering_video.c
│ ├── Makefile
│ ├── metadata.c
│ └── muxing.c
├── ffprobe.xsd
├── libvpx-1080p50_60.ffpreset
├── libvpx-1080p.ffpreset
├── libvpx-360p.ffpreset
├── libvpx-720p50_60.ffpreset
├── libvpx-720p.ffpreset
├── libx264-ipod320.ffpreset
└── libx264-ipod640.ffpreset

我只需要 ffmpegbin 下放入我的项目的 <project-root>/res/raw目录?

什么是最简单的电话 ffmpeg并用命令字符串喂它?

我用有限的解码器和解复用器编译了 FFmpeg,因为我只需要音频提取。

见: How can I get FFmpeg to locate installed libraries when --sysroot is pointing to another directory?

我会在后台使用它,并在完成时在通知栏中通知用户。

我知道,在 SO 上,还存在其他类似的问题,但它们有点模糊或令人困惑,至少对我而言。我明白在这一点上我缺乏能力(实际上我的应用程序是由网络上的 java-code-snippets 组成的拼图,它们一起工作)。

我会很感激一些指导。
谢谢。

最佳答案

尽管放置在 bin 文件夹中的可执行“ffmpeg”将在 Root手机上运行,​​但它实际上并不是在适合一般分发的应用程序中分发 ffmpeg 的最佳方式。

更好的接口(interface)是使用标准 JNI 接口(interface),其中 android 加载允许调用 ffmpeg 的共享库,然后调用 shell,android 方法用作 ffmpeg 的 CLI exec 的包装器。

要获得一个很好的示例,请参阅 github 上的“android-ffmpeg-x264”项目.

android JNI接口(interface)为here

关于android - 从java代码调用为Android编译的FFmpeg可执行文件的简单方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14725097/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com