将ffmpeg命令行转换为C ++编解码器设置 [英] Translating ffmpeg command line to C++ codec settings

查看:736
本文介绍了将ffmpeg命令行转换为C ++编解码器设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++中一直在ffmpeg做一些工作。
关于编码器设置的大多数帮助都解释为命令行选项。
例如(从ffmpeg网站取得):

  -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1/2'

但请注意'-g 100'导致某些解码器出现问题。要尝试的东西:

 '-bf​​ 2','-flags qprd','-flags mv0' ' -  flags skiprd。 

当您要在C中设置这些选项时,这并不真正有用。
例如我设法在AVCodecContext 结构中找到 int trellis; ,这样一来就解决了,但是其他人呢?



有没有办法确定什么命令行参数对应于什么AVCodecContext成员?
我尝试过这样设置:

  AVCodecContext * c; 
av_opt_set_int(c-> priv_data,cmp,2,0);

但这会返回该选项不存在的错误代码。
我也试过:

  av_opt_set(c-> priv_data,cmp,2 0); 

我仍然收到该选项不存在的错误。



所以,有没有办法确定哪些AVCodecContext成员我应该设置等于上面的ffmpeg命令行参数?

解决方案

你做错了,交易;



av_opt_set (和朋友)采取类型为 AVClass 证明)。不要触摸 priv_data



您应该注意到 AVCodecContext 是一个 AVClass 因为它的第一个成员是一个 AVClass (或多或少如何继承(滥用该术语)适用于C)。



简而言之,你应该做的是:

  AVCodecContext * c; 
av_opt_set_int(c,cmp,2,0);

如果你想知道一个特定的类可以采取什么选项,只要看看源码。例如,libopenjpeg编码器需要许多选项。 avcodec / avformat中的其他课程以非常相似的方式定义了它们所需的选项。当您执行ffmpeg的长期帮助时,这些选项将被转储出来,但有时候可能会对源代码有所帮助。



此外,为了将来参考,并帮助您,您可能需要阅读此如何设置不采用参数的选项。


I've been doing some work in ffmpeg for a while in C++. Most of the help regarding encoder settings is explained as command line options. For example (taken from the ffmpeg site):

-mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -pass 1/2’ 

but beware the ’-g 100’ might cause problems with some decoders. Things to try:

 ’-bf 2’, ’-flags qprd’, ’-flags mv0’, ’- flags skiprd.

This is not really usefull when you want to set these options in C. For example I managed to find int trellis; in the AVCodecContext struct so that is one solved, but what about the others?

Is there a way to determine what command line parameters correspond to what AVCodecContext members ? I tried setting them like this:

AVCodecContext* c;
av_opt_set_int(c->priv_data, "cmp", 2, 0);

But this returns an error code that the option does not exist. I've also tried:

  av_opt_set(c->priv_data, "cmp", "2", 0);

I still get the error that the option does not exist.

So, is there a way to determine what AVCodecContext members I should set that are equivalent to the ffmpeg command line parameters above ?

解决方案

You're doing it wrong™

av_opt_set (and friends) take an object of type AVClass (proof). Don't touch priv_data.

You should notice that AVCodecContext is an AVClass because it's first member is an AVClass (which is more or less how "inheritance" (to abuse the term) works in C).

In short, what you should be doing is:

AVCodecContext* c;
av_opt_set_int(c, "cmp", 2, 0);

If you want to know what options a particular class can take, just look at the source. For example, the libopenjpeg encoder takes many options. Other classes in avcodec/avformat define the options they take in a very similar way. These options are dumped out when you do ffmpeg's long help, but sometimes going to the source can shed some light on things.

Also, for future reference, and to help you, you might want to read this for how options that don't take parameters are set.

这篇关于将ffmpeg命令行转换为C ++编解码器设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆