gpt4 book ai didi

ffmpeg - 如何使用 avformatcontext 激活 latm 编码

转载 作者:行者123 更新时间:2023-12-04 23:27:11 33 4
gpt4 key购买 nike

我正在尝试设置 rtp encoderacc latm support ,但无论我尝试什么,我似乎都无法让它工作:

AVCodec *codec = avcodec_find_encoder_by_name("aac");
AVCodecContext *codecCtx = avcodec_alloc_context3(codec);

AVFormatContext *formatCtx = avformat_alloc_context();
avformat_alloc_output_context2(&formatCtx, NULL, "rtp", NULL);
av_opt_set(m_formatCtx, "rtpflags", "+latm",0 );
formatCtx->flags |= (AVFMT_FLAG_MP4A_LATM | AVFMT_FLAG_BITEXACT);

AVStream *avStream = avformat_new_stream(formatCtx, codec);
avStream->codec = codecCtx;

我使用了错误的编解码器吗?我跑了 ffmpeg -codecs | grep latm找到唯一用于解码的 latm 编解码器,因此 latm 编码仅可用作输出格式。我从 rtpenc_chain source 中找到了这些标志.

当我的目标是“MP4A-LATM”时,我的输出始终是“MPEG4-GENERIC”。

在此先感谢您的帮助!

最佳答案

您需要在标题中添加 rtp 标志,无需编辑 avcontext 标志。所以:

AVDictionary *optionsDict = nullptr;
av_dict_set(&optionsDict, "rtpflags", "latm",0 );
avformat_write_header(formatCtx,&optionsDict) != 0);

关于ffmpeg - 如何使用 avformatcontext 激活 latm 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40712774/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com