-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不进行 seek ,从头播放 1 秒左右的噪音 #39
Comments
以下是可能没啥用的流水账。 在 Ubuntu 和 macOS 上,不进行开头的 seek 直接播放,当噪音出现时,我注意到 Application Output 输出了一行或多行的 由于
我不明白这意味着什么,因为之前(在 Ubuntu 上开发时)见到过许多次了,有时还会同时出现
Beslyric-for-X 也使用的 decodeLen = avcodec_decode_audio4(MS->acct, pframe, &got_frame, &packet);
if (decodeLen < 0) // 出错,跳过
+ {
+ qDebug()<<decodeLen;
break;
+ } 当噪音出现时:
从windows - ffmpeg exit status -1094995529 - Stack Overflow可知,“-1094995529”是
此处 “似乎发现了什么?” 接着,我尝试在 if(m_MS.audioq.first_pkt != nullptr){
auto plist = m_MS.audioq.first_pkt;
auto buf = plist->pkt.buf;
auto data = plist->pkt.data;
auto size = plist->pkt.size;
auto pos = plist->pkt.pos;
qDebug()<<"{";
qDebug()<<"\tpkt.buf"<<buf;
qDebug()<<"\tpkt.data[0]"<<data[0];
qDebug()<<"\tpkt.size"<<size;
qDebug()<<"\tpkt.pos"<<pos;
qDebug()<<"}";
qDebug()<<m_MS.audio_clock;
} 输出:
我测试了其它的歌曲,发现在出现噪音时:
到这里,我就进行不下去了,因为实在不懂 FFmpeg 这些。 我把注意力回到从头播放一首音乐时输出的 //读取音频的专辑图片
// read the format headers
if (pFormatCtx->iformat->read_header(pFormatCtx) < 0) {
printf("No header format");
//return;
} 它被执行后,输出了 问题暂时“解决”。 |
这里有一个比较坑的地方,不过不确定是不是我自己的问题。 虽然在各个平台上 我 Windows 上用的 MSVC2015 32bit ,Ubuntu 和 macOS 都是用的 GCC x86_64 ,不知道跟这个有无关系。 另外,我这边 Windows 上 Application Output 的输出似乎没有 Ubuntu 上的那么流畅,体验稍差。就开发 Beslyric-for-X 来说, Linux 环境可能是个好选择。 |
试了一下,windows 下确实是加上 av_log_set_level(AV_LOG_DEBUG) 才看到了Header missing信息 |
这个问题可能作者也有研究过,但是到目前似乎还没有完全被解决。
我把我的发现放在这里,给以后(重新写代码时)做参考。
环境:
我把刚测试出来的一个“解决方法”写在这里,稍后会补充探究过程。
在
PlayThread::initDeviceAndFfmpegContext()
方法中,移除整个关于AVFormatContext->iformat->read_header(struct AVFormatContext *)
的代码:https://github.com/Beslyric-for-X/Beslyric-for-X/blob/0dee64a8834f1ba294b12f99fee97acc438ee500/Entities/MusicPlayer/musicPlayer.cpp#L391-L396
接着把
PlayThread::generateAudioDataLoop()
方法中的seekToPos(10)
注释掉,然后运行程序,播放音乐,开头的噪音应该就会消失了。然而我并不知道这背后的原理……
The text was updated successfully, but these errors were encountered: