diff --git a/android/src/main/kotlin/top/skychip/video_decode_plugin/VideoDecoder.kt b/android/src/main/kotlin/top/skychip/video_decode_plugin/VideoDecoder.kt index c6223f6..9565448 100644 --- a/android/src/main/kotlin/top/skychip/video_decode_plugin/VideoDecoder.kt +++ b/android/src/main/kotlin/top/skychip/video_decode_plugin/VideoDecoder.kt @@ -162,6 +162,7 @@ class VideoDecoder( // 启动渲染线程 renderThreadRunning = true renderThread = Thread { + var hasNotifiedFlutter = false var renderedFrameCount = 0 // 渲染帧计数器 while (renderThreadRunning) { // 计算每帧渲染间隔 @@ -172,10 +173,10 @@ class VideoDecoder( val frame = outputFrameQueue.take() frame.codec.releaseOutputBuffer(frame.bufferIndex, true) renderedFrameCount++ - // 每累计renderFps帧回调一次onFrameRendered - if (renderedFrameCount >= renderFps) { - // 回调到Flutter端 通知解码并渲染完81帧了 + // 只在首次渲染时回调Flutter + if (!hasNotifiedFlutter) { mainHandler.post { onFrameRendered() } + hasNotifiedFlutter = true } } catch (e: Exception) { Log.e(TAG, "[RenderThread] Exception", e) diff --git a/lib/video_decode_plugin.dart b/lib/video_decode_plugin.dart index 0b4c2d2..daa8f2c 100644 --- a/lib/video_decode_plugin.dart +++ b/lib/video_decode_plugin.dart @@ -129,6 +129,7 @@ class VideoDecodePlugin { required int timestamp, required int frameSeq, bool splitNalFromIFrame = false, + int? refIFrameSeq, // P帧时可选 }) async { if (splitNalFromIFrame && frameType == 0) { // 优先使用缓存的SPS/PPS