![](/img/trans.png)
[英]Video length is different from starting and ending time stamp in MediaCodec
[英]Rendering same video to 2 Surfaces from a MediaCodec
MediaCodec 有 2 種操作方式:您可以傳遞一個Surface進行渲染,或者您讀取 output 緩沖區並自己將其繪制到屏幕上。
在第一種情況下,我通過一個表面:是否可以將相同的 MediaCodec 解碼視頻繪制到 2 個表面?
解碼循環看起來像這樣:
int outputBufferId = codec.dequeueOutputBuffer(…);
if (outputBufferId >= 0) {
//Do nothing, the MediaCodec will automatically draw to our surface
//But how to draw to 2 surfaces?
codec.releaseOutputBuffer(outputBufferId, …);
} else if (outputBufferId == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
// Subsequent data will conform to new format.
// Can ignore if using getOutputFormat(outputBufferId)
outputFormat = codec.getOutputFormat(); // option B
}
能夠一次繪制多個表面的唯一方法是使用 OpenGL。
如果你願意,我可以給你一些建議。
首先,您需要一個由表面紋理支持的表面。 表面紋理是解碼器將解碼幀排隊的地方,您可以從那里檢索它。 一旦表面紋理中的框架可用,您將使用 OpenGL(每個表面連接多個 EGLSurface。您可以使用 eglCreateWindowSurface 創建這樣的表面)。
一旦你連接了你的表面和一個有效的 EGL 上下文,只需使用 eglMakeCurrent 並傳入你創建的 EGL 表面,每個繪制操作一個。 因此 eglMakeCurrent 將允許您一次在一個表面上繪制,並且您可以為您擁有的每個表面執行此操作。 您通常可以在 grafika 中找到其中一些示例
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.