android ffmpeg halfninja av_open_input_file 返回 -2 (没有这样的文件或目录)

发布于 2024-12-11 17:57:03 字数 2815 浏览 0 评论 0原文

中描述的代码和方法为 Android 构建了 ffmpeg

我已经使用https://github.com/halfninja /android-ffmpeg-x264

使用在 Windows 上的 VirtualBox 中运行的 Ubuntu。然后,我将 libvideokit.so 复制到所提供项目的 Windows 副本的 Project\libs\armeabi 文件夹中。从那里我可以在我的 Android 设备上从 Eclipse 运行 ProjectTest。我可以看到 ffmpeg 代码正在执行,但是当它到达打开输入文件的位置时,它给了我指示的错误。 对此问题进行了一些讨论

我注意到FFMpeg 在Android上,对libavcodec函数的未定义引用,尽管它在命令行上列出

但解决方案没有帮助,因为在此版本中启用了文件协议,并且我还尝试将“file:”放在前面文件路径无济于事。为了完整起见,我尝试设置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!

I have built ffmpeg for Android using the code and method described at

https://github.com/halfninja/android-ffmpeg-x264

using Ubuntu running in VirtualBox on windows. I then copied libvideokit.so into the Project\libs\armeabi folder of a Windows copy of the provided projects. From there I was able to run the ProjectTest from Eclipse on my Android device. I can see the ffmpeg code being executed but when it gets to the point of opening the input file it gives me the indicated error. I have noticed some discussion of this problem at

FFMpeg on Android, undefined references to libavcodec functions, although it is listed on command line

but the solutions have not helped since the file protocol is enabled in this build and I also tried putting "file:" in front of the filepath to no avail. For completeness I tried setting minimal_featureset=0 to enable all the defaults but this gives me the same error. Below is a snapshot of the logcat from Eclipse showing the output from Videokit with an extra call to LOGE to display the result from av_open_input_file. Any suggestions of things to try would be greatly appreciated.

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏末的微笑 2024-12-18 17:57:03

问题出在权限上。在 Android 上,我们以系统所有者身份安装了 SD 卡,但没有 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。就是这样!

The problem is in permissions. On android we have sdcard mounted with system as owner, but without rwx. But ffmpeg checks that:

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;
}

Change this function like this:

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;
}

And rebuild your ffmpeg. And that`s it!

以可爱出名 2024-12-18 17:57:03

实际上,我在使用此版本编译 FFMpeg 时遇到了同样的问题:
http://www.roman10.net/?p=389

并启用所有可以启用(摆脱 --disable-everything 选项)。

如果您有一些想法,我很感兴趣:)

编辑:
在 HalfNinja 网站上,内容如下:
“...目前我在输入文件方面遇到一些问题(我认为大多数输入都很好,但它无法识别 JPEG 序列)。”
:(

Actually, I have the same issue while compiling FFMpeg with this version :
http://www.roman10.net/?p=389

And enabling all that can be enabled ( getting rid of the --disable-everything option ).

If you have some idea, I'm interested :)

Edit :
On the HalfNinja site, here is what is written :

"...at the moment I’m having some problems with input files (I think most inputs are fine but it doesn’t recognise JPEG sequences)."

:(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文