当我试图将mp4转换为flv时,会得到以下错误:
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
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);
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])
这个错误意味着什么?这个标签是在哪里定义的?为什么复制参数是不够的?
发布于 2022-11-01 07:31:01
将codec_tag (out_ for >codecpar-> codec _ tag )设置为0,或者在每个输出流的for循环中设置相应的AVI编解码器标记。
https://stackoverflow.com/questions/69866436
复制相似问题