【问题标题】:invalid conversion from int to avcodecid (ffmepg)从 int 到 avcodec 的无效转换 (ffmpeg)
【发布时间】:2015-03-18 16:45:59
【问题描述】:

今天我在CodeBlocks中运行ffmpeg示例c程序,报错:

invalid conversion from int to avcodecid[-fpermissive]

我把部分代码放在这里:

static AVCodec **codec;
static AVCodecContext *c= NULL;
static int  ret,   got_output;
static FILE *f;
static AVFrame *frame;
static AVPacket pkt;
static uint8_t endcode[] = { 0, 0, 1, 0xb7 };
enum AVCodecID codec_id;

*codec = avcodec_find_encoder(codec_id);

无论我使用*codec 还是codec,它都会给出同样的错误,我检查了我的opencv 和ffmpeg 版本,所有最新版本的2.4.10 opencv 和2.5.3 ffmpeg。 如果我点击错误,它会将我定向到另一个文件avcode.h,给出错误

初始化 'AVcodec* acvodec_find_encoder(AVCodeciD)'[-fpermissive] 的 agument 1

在文件的这一行

frame = avcodec_alloc_frame();

【问题讨论】:

  • avcodec_find_encoder的返回类型是什么?此外,您还在使用 codec_id uninitialized —— 是在您的原始代码中,还是您删减的内容?
  • avcodec_find_encoder的参数类型是AVCodecID,而不是intHere 是枚举的文档。
  • 是的,我已将类型从 int 更改为 AVCodec 并解决了问题,抱歉我的问题,我没有放完整程序

标签: c++ c ffmpeg


【解决方案1】:

这个错误信息

从 int 到 avcodecid 的无效转换[-fpermissive]

表示没有从int 到类型enum AVCodecID 的隐式转换。所以你需要显式地强制转换整数到枚举的类型。

我想你包含了所有必需的标题,不是吗?

这个错误信息

初始化 'AVcodec* 的 agument 1 acvodec_find_encoder(AVCodeciD)'[-fpermissive]

表示您在函数调用中使用了错误的参数类型。您必须在调用它之前检查函数声明并为其参数提供正确的参数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-19
    • 2020-01-15
    • 2012-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多