FFMPEG设置网络摄像头编码器c++
FFMPEG Set Webcam Encoder C++
我试图在windows中使用FFMPEG C API捕获网络摄像头流。我可以使用以下命令行选项做我想做的事情:
ffmpeg -f dshow -vcodec mjpeg -s 1280x720 -framerate 30 -i video=HX-A1:audio="Microphone (HX-A1)" outputFile.mpg
我已经开始与转码。c的例子,并得到了它的工作,以记录一个虚拟的网络摄像头,如屏幕捕捉记录器。然而,我需要为我的真实网络摄像头设置编码器选项,因为它默认为160x120原始视频,我更喜欢更高的分辨率。我正在尝试以下设置相机编码器选项,但它似乎没有做任何事情。
AVDictionary *opt = NULL;
av_dict_set(&opt, "vcodec", "mjpeg", 0);
av_dict_set(&opt, "s", "1280x720", 0);
av_dict_set(&opt, "framerate", "30", 0);
if ((ret = avformat_open_input(&ifmt_ctx, filename, inputFormat, &opt)) < 0) {
av_log(NULL, AV_LOG_ERROR, "Cannot open input filen");
return ret;
}
是否有另一种方法来设置输入选项,以告诉相机使用什么编解码器在我的命令行示例中完成?
解决了,我必须先初始化我的AVFormatContext,然后打开MJPEG解码器,并在打开之前设置AVFormatContext的视频解码器和编解码器ID。
AVDictionary* dictionary = NULL;
av_dict_set(&dictionary, "video_size", "1280x720", NULL);
av_dict_set(&dictionary, "framerate", "30", NULL);
ifmt_ctx = avformat_alloc_context();
ifmt_ctx->video_codec_id = AV_CODEC_ID_MJPEG;
av_format_set_video_codec(ifmt_ctx, opened_mjpeg_codec);
avformat_open_input(&ifmt_ctx, filename, inputFormat, &dictionary);
相关文章:
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 绝对编码器十六进制输入
- *新的编码器*格式和运算符
- Arduino RPM代码与正交编码器600ppr
- 如何获得GUID编码器,如果我在IMFTransform上有一个指针?
- 如何将 MATLAB 图像处理库内置函数转换为 MATLAB 编码器代码生成不支持的 C++?
- Openh264 编码器增加了 IDR 或 I 帧的数量
- 确定输入"conscalc: calc"的类型时出错。不能联合编码器。具有不同字段集的结构类型
- 将原始视频图像转换为VPX编码器的I420
- 使用 MATLAB 编码器将代码从注册估算器应用程序导出到C++
- 如何读取旋转编码器
- 防止编码器错误 - 忘记在"std::enable_if<>::type"中添加"::type" (SFINAE)
- 如何使用Imebra库将压缩像素(用我自己的编码器压缩)回到DICOM图像文件中
- 如何从Intel MFT编码器的D11纹理创建IMFSample
- Matlab 编码器转换可变大小单元格错误
- 使用 Arduino 将位置编码器值转换为 RPM 时出现问题
- 防止编码器错误 - 通过参考(悬挂指针)返回临时值
- 编码器的PDF规格:Adobe或ISO
- Matlab 编码器错误 "for loop index expressions.." 如何修改代码?
- C和MATLAB:为什么MATLAB中的一行成为MATLAB编码器生成的C 代码中的许多行