如何加载NDK的视频文件(位于资源文件夹中)? [英] How to load a video file(located in assets folder ) in NDK?
问题描述
我由Android NDK执行的ffmpeg,我能够运行一个样,在这里[https://github.com/ccggaass/android-ffmpeg-sample]
I am executing ffmpeg by android ndk, I am able to run an sample, here [https://github.com/ccggaass/android-ffmpeg-sample].
我要放视频android的资产文件夹中,因此如何将这些文件传递给ffmpeg的API:
I want to put the video in android assets folder, so how to pass this file to the ffmpeg api:
av_open_input_file(安培; pFormatCtx, 文件:/sdcard/vid.3gp的,NULL,0,NULL);
av_open_input_file(&pFormatCtx, "file:/sdcard/vid.3gp", NULL, 0, NULL);
有谁知道如何将文件传递给AV LIB?
Does anyone know how to pass the file to av lib?
推荐答案
确认该资产不会成为COM pressed当APK建成。 (这样我们就可以访问它的文件描述符)
确保ffmpeg的是建立与管道协议的支持。
抓住从AAsset_manager资产文件描述符。
建立文件名像这样...
Make sure the asset wont be compressed when the APK is built. ( so we can access its file descriptor ) Make sure Ffmpeg is built with the pipe protocol support. Grab the assets file descriptor from the AAsset_manager. build the filename like so...
字符FN [32];
sprintf的(FN,管子://%D,your_assets_fd);
char fn[32]; sprintf(fn,"pipe://%d", your_assets_fd);
打开它,像这样......
av_open_input_file(X,FN,...);
open it like so... av_open_input_file( x, fn, ... );
好运。
P.S。不要硬code中的/ SD卡/路径。
P.S. don't hard-code the /sdcard/ path.
这篇关于如何加载NDK的视频文件(位于资源文件夹中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!