FFMPEG交友对象带来的音频假象 [英] FFMPEG Seeking brings audio artifacts

查看:394
本文介绍了FFMPEG交友对象带来的音频假象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm使用的ffmpeg实现音频解$ C $铬。
当读取的音频,甚至已经寻求工作,我不能在应用程序启动后寻求读取音频右想出一个办法来清除寻求所以以后我也没有文物缓冲区。

I´m implementing a audio decoder using ffmpeg. While reading audio and even seeking already works, I can´t figure out a way to clear the buffers after seeking so I have no artifacts when the app starts reading audio right after seeking.

AV codec_flush_buffers doesn't似乎对内部缓冲区任何影响。此问题恰好与所有德codeRS(MP3,AAC,WMA,...),但PCM / WAV(其中doesn't使用内部缓冲区来保存数据以取消code,因为声音是不是COM pressed)。

avcodec_flush_buffers doesn´t seem to have any effect on the internal buffers. This issue happens with all decoders (mp3, aac, wma, ...) but PCM/WAV (which doesn´t use internal buffers to hold data to decode since the audio is not compressed).

在code段是简单的:

The code snippet is simple:

av_seek_frame(audioFilePack->avContext, audioFilePack->stream, posInTimeFrame, AVSEEK_FLAG_ANY);
avcodec_flush_buffers(audioFilePack->avContext->streams[audioFilePack->stream]->codec);

解释:

audioFilePack->avContext = FormatContext
audioFilePack->stream = Stream Position (also used to read audio packets)
audioFilePack->avContext->streams[audioFilePack->stream]->codec = CodecContext for the codec used

这是我应该做的,所以我可以寻求和获得无残留音频任何想法?
谢谢!

Any ideas on what I should do so I can seek and get no residual audio? Thanks!

推荐答案

这是在ffmpeg的一个bug。内部缓冲区不会被刷新,因此,当你去冲洗后,得到一个数据包/帧,你得到pre-寻求数据。这似乎是固定为12年3月16日,所以你可以纳入这个自己解决,或升级的ffmpeg。

It's a bug in ffmpeg. The internal buffers aren't being flushed, and therefore when you go to get a packet/frame after flushing, you're getting the pre-seek data. It appears to be fixed as of 3-16-12, so you could incorporate this fix yourself, or upgrade ffmpeg.

http://permalink.gmane.org/gmane.comp。 video.libav.devel / 23455

作为更新,上面的错误确实是个问题,但有一个第二缺陷与AAC明确。

As an update, the bug above is indeed a problem, but there's a second bug with AAC specifically.

由于五个月前,其他用户发现了这个错误,并且据报道是固定的。
https://ffmpeg.org/trac/ffmpeg/ticket/420

As of five months ago, another user found this bug, and it was reported to be fixed. https://ffmpeg.org/trac/ffmpeg/ticket/420

此修复程序是被添加到aacdec.c它清除其内部缓冲区刷新功能。
问题是,有在aacdec.c定义了两个去codeRS,只有一个被赋予了冲洗功能指针。如果使用其他的(多见)代codeR,它仍然不会正确清除。

The fix was a flush function being added to aacdec.c which clears its internal buffers. The problem is there are two decoders defined in aacdec.c, and only one was given the flush function pointer. If you use the other (more common) decoder, it still won't be cleared properly.

如果您在建立自己的ffmpeg的位置是,该修补程序是添加
.flush =平齐,
至AV $ C $立方厘米ff_aac_de codeR的定义的底部(这是在文件的底部。)

If you're in a position to build ffmpeg yourself, the fix is to add .flush = flush, to the bottom of the definition of AVCodec ff_aac_decoder (which is at the bottom of the file.)

我就让FFmpeg的家伙知道,所以希望它可以被包含在主要的分支。

I'll let the ffmpeg guys know so hopefully it can be included in the main branch.

这篇关于FFMPEG交友对象带来的音频假象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆