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

咨询个MediaSync的问题 #4087

Closed
jiajialaixi opened this issue Jan 23, 2025 · 5 comments
Closed

咨询个MediaSync的问题 #4087

jiajialaixi opened this issue Jan 23, 2025 · 5 comments

Comments

@jiajialaixi
Copy link

jiajialaixi commented Jan 23, 2025

MediaSync同步音视频 使用SurfaceView中surface 可以更新画面 如果使用TextureView 的surface 就无法更新画面 这是什么原因导致的

@CarGuo
Copy link
Owner

CarGuo commented Jan 25, 2025

不理解

@jiajialaixi
Copy link
Author

MediaSync sync = new MediaSync();
sync.setSurface(surface);
Surface inputSurface = sync.createInputSurface();
...
// MediaCodec videoDecoder = ...;
videoDecoder.configure(format, inputSurface, ...);
...
sync.setAudioTrack(audioTrack);

sync.setSurface(surface); 传入的是SurfaceView 生成的surface 画面就现实正常 如果是 纹理的 surface 画面就出现只有第一帧或者黑屏

@CarGuo
Copy link
Owner

CarGuo commented Jan 30, 2025

哦,我想着 GSY 也开发这么底层接口,说的是单纯 MediaSync 问题啊····· 理论上 SurfaceView 和 TextureView 的区别,主要还是在于设备硬件加速支持上,TextureView 会用 GPU 将 TextureView 的内容合成到视图层次结构中

比如

缩放 SurfaceView 需要用 FrameLayout 的自定义实现,WindowManager 需要向 SurfaceFlinger 发送新的窗口位置和尺寸值。

缩放 TextureView 的 SurfaceTexture 需要使用 TextureView#setTransform() 配置转换矩阵。

所以如果黑屏,主要可能是在于 app 没开启硬件加速或者硬件支持问题?

@jiajialaixi
Copy link
Author

设备硬件是支持的 并且也是开启了硬件加速

@CarGuo
Copy link
Owner

CarGuo commented Feb 1, 2025

你这么说,我也没办法猜出来,哈哈哈

@CarGuo CarGuo closed this as completed Feb 11, 2025
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