如何在基于ffmpeg的程序中以编程方式传递VP8编码器选项
How to pass VP8 encoder option programmatically in ffmpeg based program
我正在基于标准ffmpeg转码器示例构建使用ffmpeg库的程序。我的目标是建立视频转码器,它编码任何合适的视频(即ffmpeg可以读取)到WEBM格式。问题是我如何传递选项到VP8编码器来控制输出视频质量和其他参数?我的意思是通过c++代码传递这些选项
使用以下代码:
AVDictionary *options = NULL;
AVCodec *codec = avcodec_find_encoder(AVCODEC_ID_VP8);
AVCodecContext *ctx = avcodec_alloc_context3(codec);
av_dict_set(&options, "option", "value", 0);
int res = avcodec_open2(ctx, codec, &options);
if (res < 0)
error();
while (..) {
res = avcodec_encode_video2(ctx, ..);
if (res < 0)
error();
}
avcodec_close(ctx);
avcodec_free_context(ctx);
相关的"选项"/"值"对是您从vp8编码指南中获得的任何内容,例如FFmpeg wiki。例如,要设置比特率为1mbps (wiki中的第一个例子),使用:
av_dict_set_int(&options, "b", 1024 * 1024, 0);
或
av_dict_set(&options, "b", "1M", 0);
我建议使用VP9而不是VP8,使用VP8你不会得到很好的质量,但这显然是你的选择。
相关文章:
- 使用 Gtkmm 以编程方式选择 Gtk::TextView 中的文本
- 在没有管理员权限的情况下,在 c++ 中以编程方式将程序添加到启动
- 如何以编程方式将音频从任何录制设备路由到任何播放设备
- 我是否可以使用 win32 句柄以编程方式记录发送到/接收到 USB/COM 的内容
- 如何以编程方式使窗口全屏显示?
- 终端如何在 shell 提示符下以编程方式阻止退格,以便您无法在其上退格,例如 $ 表示 bash 或 C:\blah\>
- 如何使用打印到 PDF 打印机在 MFC 和 CView 中以编程方式打印而不提示输入文件名?
- 如何以编程方式显示功能区按钮的下拉菜单?
- 是否可以以编程方式构造 std::initializer_list?
- 在 Visual C++ 中以编程方式更改按钮的背景图像
- 附加调试器并以编程方式获取变量地址 Visual Studio
- 以编程方式重新连接断开的 VHD 链
- 如何以编程方式获取任务管理器进程CPU使用率(不是PerfMon API)
- 以编程方式在任何按钮上突出显示 Qt 鼠标悬停按钮
- 以编程方式防止重命名或删除文件,但仍使其可写
- 以编程方式连接子图
- 如何以编程方式区分在内存的堆和堆栈部分创建的对象
- 如何以编程方式从PKCS7中提取CA、多个CA和公共证书/密钥
- 如何以编程方式为应用程序创建文件夹,以使用 BOX REST API 在其中上传内容
- 无法以编程方式上传数据到Zookeeper