- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我已经使用描述的代码和方法为 Android 构建了 ffmpeg
https://github.com/halfninja/android-ffmpeg-x264
使用在 Windows 上的 VirtualBox 中运行的 Ubuntu。然后,我将 libvideokit.so 复制到所提供项目的 Windows 副本的 Project\libs\armeabi 文件夹中。从那里我能够在我的 Android 设备上从 Eclipse 运行 ProjectTest。我可以看到正在执行的 ffmpeg 代码,但是当它到达打开输入文件的位置时,它会给我指示的错误。我注意到一些关于这个问题的讨论
但是解决方案没有帮助,因为在此版本中启用了文件协议(protocol),我也尝试将“文件:”放在文件路径前面但无济于事。为了完整起见,我尝试设置 minimal_featureset=0 以启用所有默认值,但这给了我同样的错误。下面是 Eclipse 的 logcat 快照,显示了 Videokit 的输出,并额外调用了 LOGE 以显示 av_open_input_file 的结果。任何尝试的建议都将不胜感激。
10-23 11:57:33.888: DEBUG/Videokit(4830): run() called
10-23 11:57:33.888: DEBUG/Videokit(4830): run passing off to main()
10-23 11:57:33.904: DEBUG/Videokit(4830): main(): registering all modules
10-23 11:57:33.927: DEBUG/Videokit(4830): main(): registered everything
10-23 11:57:33.927: DEBUG/Videokit(4830): main(): initting opts
10-23 11:57:33.943: DEBUG/Videokit(4830): main(): initted opts.
10-23 11:57:33.943: ERROR/Videokit(4830): ffmpeg version N-30996-gf925b24, Copyright (c) 2000-2011 the FFmpeg developers
10-23 11:57:33.943: ERROR/Videokit(4830): built on Oct 21 2011 13:54:03 with gcc 4.4.3
10-23 11:57:33.943: ERROR/Videokit(4830): configuration: --enable-cross-compile --arch=arm5te --enable-armv5te --target-os=linux --disable-stripping --prefix=../output --disable-neon --enable-version3 --disable-shared --enable-static --enable-gpl --enable-memalign-hack --cc=arm-linux-androideabi-gcc --ld=arm-linux-androideabi-ld --extra-cflags='-fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated' --disable-everything --enable-decoder=mjpeg --enable-demuxer=mjpeg --enable-parser=mjpeg --enable-demuxer=image2 --enable-muxer=mp4 --enable-encoder=libx264 --enable-libx264 --enable-decoder=rawvideo --enable-protocol=file --enable-hwaccels --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-network --enable-filter=buffer --enable-filter=buffersink --disable-demuxer=v4l --disable-demuxer=v4l2 --disable-indev=v4l --disable-indev=v4l2 --extra-cflags='-I../x264 -Ivideokit' --extra-ldflags=-L../x264
10-23 11:57:33.943: DEBUG/Videokit(4830): main(): parsing options
10-23 11:57:33.943: DEBUG/Videokit(4830): parse_options has 4 options to parse
10-23 11:57:33.951: ERROR/Videokit(4830): opt_input_file av_open_input_file /mnt/sdcard/fun/snap0000.jpg -2
10-23 11:57:33.951: ERROR/Videokit(4830): /mnt/sdcard/fun/snap0000.jpg: No such file or directory
10-23 11:57:33.951: ERROR/Videokit(4830): ffmpeg_exit(1) called!
最佳答案
问题出在权限上。在 android 上,我们将 sdcard 作为所有者安装在系统上,但没有 rwx。但是 ffmpeg 检查:
avformat/file.c:
static int file_check(URLContext *h, int mask)
{
struct stat st;
int ret = stat(h->filename, &st);
if (ret < 0)
return AVERROR(errno);
ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
return ret;
}
像这样改变这个函数:
static int file_check(URLContext *h, int mask)
{
struct stat st;
int ret = stat(h->filename, &st);
if (ret < 0)
return AVERROR(errno);
ret |= st.st_mode&S_IRUSR ? mask&AVIO_FLAG_READ : 0;
ret |= st.st_mode&S_IRGRP ? mask&AVIO_FLAG_READ : 0;
ret |= st.st_mode&S_IROTH ? mask&AVIO_FLAG_READ : 0;
ret |= st.st_mode&S_IWUSR ? mask&AVIO_FLAG_WRITE : 0;
ret |= st.st_mode&S_IWGRP ? mask&AVIO_FLAG_WRITE : 0;
ret |= st.st_mode&S_IWOTH ? mask&AVIO_FLAG_WRITE : 0;
return ret;
}
并重建你的 ffmpeg。就是这样!
关于android ffmpeg halninja av_open_input_file 返回 -2(没有这样的文件或目录),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7867853/
我正在尝试使用 av_open_input_file() 连接到一些 RTSP 流,如下所示: AVFormatContext* ic; avcodec_register_all(); av_regi
我已经使用描述的代码和方法为 Android 构建了 ffmpeg https://github.com/halfninja/android-ffmpeg-x264 使用在 Windows 上的 Vi
我是一名优秀的程序员,十分优秀!