FFMPEG寻求带来音频工件 [英] FFMPEG Seeking brings audio artifacts

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

问题描述

我使用ffmpeg实现音频解码器。
在阅读音频,甚至寻找已经工作,我不能找出一种方法来清除缓冲区寻求后,我没有工件,当应用程序开始读取音频后寻求。



avcodec_flush_buffers似乎没有对内部缓冲区有任何影响。这个问题发生在所有解码器(mp3,aac,wma,...),但是PCM / WAV(由于音频没有被压缩,它不使用内部缓冲器来保持数据解码)。



代码段很简单:

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

说明:

 code> audioFilePack-> avContext = FormatContext 
audioFilePack-> stream = Stream Position(也用于读取音频包)
audioFilePack-> avContext-> streams [audioFilePack-> stream] - > codec =编解码器的CodecContext

可以寻求并得到没有残留音频?
谢谢!

解决方案

这是ffmpeg中的一个错误。内部缓冲区不会被刷新,因此当您在刷新后获取数据包/帧时,将获得预寻找数据。它似乎是固定的3-16-12,所以你可以自己整合这个修复或升级ffmpeg。



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

作为更新,上面的bug确实是一个问题,但是有一个与AAC的第二个bug。



的五个月前,另一个用户发现了这个错误,它被报告是固定的。
https://ffmpeg.org/trac/ffmpeg/ticket/420



修复是一个刷新函数被添加到aacdec.c,它清除其内部缓冲区。
问题是在aacdec.c中定义了两个解码器,并且只有一个被赋予了flush函数指针。如果您使用其他(更常见的)解码器,它仍然无法正确清除。



如果您可以自己编译ffmpeg,将
.flush = flush,
添加到AVCodec ff_aac_decoder(位于文件底部)定义的底部。



我会让ffmpeg家伙知道,希望它可以包括在主分支。


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.

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).

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);

Explaining:

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!

解决方案

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

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

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

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.

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.)

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

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

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