首页 \ 问答 \ 如何将FFMPEG AV_CODEC_ID_PCM_S16BE音频数据提供给AudioQueue(How to feed FFMPEG AV_CODEC_ID_PCM_S16BE audio data to AudioQueue)

如何将FFMPEG AV_CODEC_ID_PCM_S16BE音频数据提供给AudioQueue(How to feed FFMPEG AV_CODEC_ID_PCM_S16BE audio data to AudioQueue)

我正在使用FFMPEG与FFmpegAudioPlayer结合进行直播。 我遇到的问题是,虽然音频可以被解码和播放,但是音频中存在持续的点击/尖叫噪声,当其他应用程序流式传输相同的源时,该噪声不存在。 所以我猜这个问题是由于我将FFMPEG AV_CODEC_ID_PCM_S16BE音频数据处理到AudioQueue之前的处理方式:

audioFormat.mFormatID = kAudioFormatLinearPCM;            
audioFormat.mFormatFlags = kAudioFormatFlagsCanonical;//kAudioFormatFlagIsBigEndian|kAudioFormatFlagIsAlignedHigh;
audioFormat.mSampleRate = pAudioCodecCtx->sample_rate;
audioFormat.mBitsPerChannel = 8*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
audioFormat.mChannelsPerFrame = pAudioCodecCtx->channels;
audioFormat.mBytesPerFrame = pAudioCodecCtx->channels * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
audioFormat.mBytesPerPacket= pAudioCodecCtx->channels * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
audioFormat.mFramesPerPacket = 1;
audioFormat.mReserved = 0;

pSwrCtx = swr_alloc_set_opts(pSwrCtx,
                                             1,//pAudioCodecCtx->channel_layout,
                                             AV_SAMPLE_FMT_S16,
                                             pAudioCodecCtx->sample_rate,
                                             1,//pAudioCodecCtx->channel_layout,
                                             AV_SAMPLE_FMT_S16,
                                             pAudioCodecCtx->sample_rate,
                                             0,
                                             0);
outCount = swr_convert(pSwrCtx,
                                             (uint8_t **)(&pOut),
                                             in_samples,
                                             (const uint8_t **)pAVFrame1->extended_data,
                                             in_samples);

还请注意,我为swr_alloc_set_opts尝试了许多不同的参数,但音频变得无法识别或噪音持续存在。

是一个带有咔嗒声的音频样本,如果有帮助的话。


I am using FFMPEG in combination with FFmpegAudioPlayer to do live streaming. The issue I am having is that, while the audio can be decoded and played, there's a constant clicking/screeching noise in the audio that isn't present when streaming the same source by other applications. So I am guess the issue arise due to how I process the FFMPEG AV_CODEC_ID_PCM_S16BE audio data before handing it to AudioQueue:

audioFormat.mFormatID = kAudioFormatLinearPCM;            
audioFormat.mFormatFlags = kAudioFormatFlagsCanonical;//kAudioFormatFlagIsBigEndian|kAudioFormatFlagIsAlignedHigh;
audioFormat.mSampleRate = pAudioCodecCtx->sample_rate;
audioFormat.mBitsPerChannel = 8*av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
audioFormat.mChannelsPerFrame = pAudioCodecCtx->channels;
audioFormat.mBytesPerFrame = pAudioCodecCtx->channels * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
audioFormat.mBytesPerPacket= pAudioCodecCtx->channels * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16);
audioFormat.mFramesPerPacket = 1;
audioFormat.mReserved = 0;

pSwrCtx = swr_alloc_set_opts(pSwrCtx,
                                             1,//pAudioCodecCtx->channel_layout,
                                             AV_SAMPLE_FMT_S16,
                                             pAudioCodecCtx->sample_rate,
                                             1,//pAudioCodecCtx->channel_layout,
                                             AV_SAMPLE_FMT_S16,
                                             pAudioCodecCtx->sample_rate,
                                             0,
                                             0);
outCount = swr_convert(pSwrCtx,
                                             (uint8_t **)(&pOut),
                                             in_samples,
                                             (const uint8_t **)pAVFrame1->extended_data,
                                             in_samples);

Please also note that I've tried many different parameters for swr_alloc_set_opts, but either the audio became unrecognizable or the noise persisted.

Here's a sample of the audio with clicking sound, if it helps.


原文:https://stackoverflow.com/questions/26499668
更新时间:2022-08-22 15:08

最满意答案

没有一种简单的方法可以为iPhone应用程序添加自定义字体。 从iOS 4开始,它变得非常容易。 以下是添加自定义字体所需执行的操作:

检查如何将ttf字体包含到iOS应用程序中


There hasn’t been an easy way to add custom fonts to your iPhone applications. As of iOS 4 it has become very easy to do. Here is what you need to do in order to add custom fonts:

Check How to include ttf fonts to iOS app

相关问答

更多
  • 你必须在设备上使用otf字体还是可以将它转换为ttf? 使用fontforge等工具将OTF字体转换为TTF字体相对简单,这可能是一个简单的解决方案。 Must you use an otf font on the device or can you convert it to ttf? It is relatively straightforward to convert an OTF font to a TTF font using a tool such as fontforge, perhaps t ...
  • 这是一个简单的例子...在项目的根目录中创建一个名为assets/fonts/的文件夹,然后粘贴TTF字体文件(在这种情况下为Verdana.ttf)。 然后,如果要将该字体应用于TextView ,请执行以下操作: import android.graphics.Typeface; public class FontSampler extends Activity { @Override public void onCreate(Bundle icicle) { super.onCrea ...
  • 是的,Marrius是对的。 在Xcode 6中,您不需要使用额外的软件,也不需要在代码文件中设置Font。 只需将您的字体文件与其他文件一起添加到项目中。 “界面”构建器将在“自定义字体列表”中显示添加的字体。 最令人惊奇的是,xcode 6在IB中立即显示应用的字体。 这是苹果公司的巨大补充。 还要确保在项目的info.plist中添加这个键“应用程序提供的字体”,并提供您的字体文件名来查看设备中的效果。 Yes, Marrius is right. In Xcode 6, you neither ne ...
  • 编辑 :所以已经有一段时间了,我想补充一下我认为是最好的方法,而且通过XML也不少! 首先,您将要创建一个新类,覆盖您要自定义的任何视图。 (例如,想要一个带有自定义字体的Button ?扩展Button )。 举一个例子: public class CustomButton extends Button { private final static int ROBOTO = 0; private final static int ROBOTO_CONDENSED = 1; pub ...
  • 没有一种简单的方法可以为iPhone应用程序添加自定义字体。 从iOS 4开始,它变得非常容易。 以下是添加自定义字体所需执行的操作: 检查如何将ttf字体包含到iOS应用程序中 There hasn’t been an easy way to add custom fonts to your iPhone applications. As of iOS 4 it has become very easy to do. Here is what you need to do in order to add ...
  • 我已经为Android Wear表面使用了大量时间的自定义字体,但我不明白为什么它应该与创建独立应用程序有任何不同。 你试过其他字体吗? 我正在为客户建立一个磨损应用程序,但我还没有进入需要更改字体的阶段。 我可以试试这个,但看看我是否有同样的结果。 I've used custom fonts multitudes of time for Android Wear watch faces, but I don't see why it should be any different for creatin ...
  • 这特别是由于在IE中的iframe中保存。 解决方案是刷新声明字体系列的css标签上的href。 这并不理想,因为它会触发css的重新加载,并且字体会瞬间闪回其后备。 如果有人有更好的解决方案,我都是眼睛。 This is specifically caused by being held in an iframe in IE. The solution is to refresh the href on the css tag that declares the font families. This i ...
  • @Kareem,我从Stackoverflow本身提示加载字体,但是不能让它在第一时间运行。 可能以下步骤可以帮到你。 将字体文件添加到项目中。 在info.plist文件中输入 如 你现在可以实现一些方法,在你的应用程序委托中的某个地方加载你的字体 - (UIFont *)CustomFontWithSize :( float)size { UIFont* customFont = [UIFont fontWithName:@"FX_Masa" size:size]; if(custom ...
  • 所以..如果你打电话给你的主题: 我的主题 在文件中: my-theme.scss 你需要在顶部添加文件: $v-font-family: "Open Sans", sans-serif; 这是其他Valo Theme变量的链接 So.. if you've called your theme: my-theme In the file: my-theme.scss You need to add at the top the file: $v-font-family: "Open Sans", sans- ...
  • 您可以使用字体为textview中的文本设置自定义字体。 因此,无论何时您需要为textview定制字体,都可以使用以下内容。 activity_main.xml中

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)