Skip to content
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

更改nv21转nv12方式后,出现音视频不同步 #829

Open
shaobin204 opened this issue Sep 30, 2021 · 3 comments
Open

更改nv21转nv12方式后,出现音视频不同步 #829

shaobin204 opened this issue Sep 30, 2021 · 3 comments

Comments

@shaobin204
Copy link

你好,最近我发现通过libyuv实现的hwYUVNV21FrameScaled(data, width, height, boundingBox)将nv21转nv12的时候比较耗时,我更改了一个for循环直接将nv21后面uv数据位置做了个对调转为nv12,效率高很多,但是推流后发现 会音视频不同步,我改回原本libyuv那个转换方式 就会同步,很奇怪,音视频同步怎么会跟这个有关系呢,会出现视频慢于音频想象,不知作者这个pts 是如何计算的呢

@begeekmyfriend
Copy link
Owner

我有点好奇libyuv的东西会比较耗时,这个工程是比较靠谱的开源项目,确定你自己改对了?

@shaobin204
Copy link
Author

@begeekmyfriend 我对比两个方法的耗时,确实是libyuv转换比较耗时,我项目开启多个camera后耗时多的更明显,我现在更改为这种方式
private byte[] nv21Tonv12(byte[] nv21, int width, int height) {
byte tmp;
int length = nv21.length;
for (int index = width * height; index < length; index++) {
if ((index + 1) % 2 == 0) {
tmp = nv21[index - 1];
nv21[index - 1] = nv21[index];
nv21[index] = tmp;
}
}
return nv21;
}
两个方法耗时对比,用这种方式确实是比较快的。效率会比较高,camera的回调帧率也提高了

@begeekmyfriend
Copy link
Owner

begeekmyfriend commented Sep 30, 2021

我的怀疑是,不同步的问题很大可能是你自己改出来的,这么个简单改法,libyuv不可能犯这种低级错误。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants