首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法使用libav:标记avc1与输出编解码器id '27‘不兼容的mux视频

无法使用libav:标记avc1与输出编解码器id '27‘不兼容的mux视频
EN

Stack Overflow用户
提问于 2021-11-06 17:45:14
回答 1查看 431关注 0票数 0

当我试图将mp4转换为flv时,会得到以下错误:

代码语言:javascript
运行
复制
Tag avc1 incompatible with output codec id '27' 

编解码器27是AV_CODEC_ID_H264

我遵循文档中的示例,可以从mp4编写图像,或者使用相同的编码器重新修改文件。https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/muxing.c

代码语言:javascript
运行
复制
AVCodec* video_codec = NULL;
// It loops through the streams and copy the parameters 
for (int i=0; I<ctx->nb_streams; i++) {
  if (ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
    video_codec = avcodec_find_decoder(stream->codepar->codec_id);
  }
}

...

const char* output_file = "output_video.flv"
// it works with mp4, not with flv
avformat_alloc_output_context2(&fmt_ctx, NULL, "flv", output_file);

...

// Error here
avformat_write_header(fmt_ctx, NULL);
代码语言:javascript
运行
复制
Output #0, flv, to 'output_video.flv':
    Stream #0:0: Video: h264 (avc1 / 0x4), none, 1920x1080, q=2-31, 6664 kb/s
    Stream #0:1: Audio: aac (mp4a / 0x5), 48000 Hz, 2 channels, 128 kb/s
[flv @ 0x5] Tag avc1 incompatible with output codec id '27' ([7][0][0][0])

这个错误意味着什么?这个标签是在哪里定义的?为什么复制参数是不够的?

EN

回答 1

Stack Overflow用户

发布于 2022-11-01 07:31:01

将codec_tag (out_ for >codecpar-> codec _ tag )设置为0,或者在每个输出流的for循环中设置相应的AVI编解码器标记。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69866436

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档