尝试使用ffmpeg使用后置摄像头

问题描述 投票:0回答:1

我尝试在 Android 环境中使用 ffmpeg c++ 打开后置摄像头:

AVFormatContext* formatCtx = avformat_alloc_context();
volatile int x = avformat_open_input(&formatCtx, "android_camera", NULL, NULL);
//x is always -2

很难找到有关 android_camera 的任何信息。你有什么想法可能是错的吗?

android c++ ffmpeg android-ndk
1个回答
0
投票

我主要错过了两件事:

avdevice_register_all();

还有

av_find_input_format("android_camera");

现在工作代码如下所示:

AVFormatContext* formatCtx = avformat_alloc_context();
avdevice_register_all();
const AVInputFormat *inputFmt = av_find_input_format("android_camera");
avformat_open_input(&formatCtx, NULL, inputFmt, NULL);
© www.soinside.com 2019 - 2024. All rights reserved.