Stay organized with collections
Save and categorize content based on your preferences.
OnFrameRenderedListener
interface OnFrameRenderedListener
Listener to be called when an output frame has rendered on the output surface
Summary
Public methods |
abstract Unit |
Called when an output frame has rendered on the output surface.
|
Public methods
onFrameRendered
abstract fun onFrameRendered(
codec: MediaCodec,
presentationTimeUs: Long,
nanoTime: Long
): Unit
Called when an output frame has rendered on the output surface.
Note: This callback is for informational purposes only: to get precise render timing samples, and can be significantly delayed and batched. Starting with Android android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE
, a callback will always be received for each rendered frame providing the MediaCodec is still in the executing state when the callback is dispatched. Prior to Android android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE
, some frames may have been rendered even if there was no callback generated.
Parameters |
codec |
MediaCodec: the MediaCodec instance This value cannot be null . |
presentationTimeUs |
Long: the presentation time (media time) of the frame rendered. This is usually the same as specified in queueInputBuffer ; however, some codecs may alter the media time by applying some time-based transformation, such as frame rate conversion. In that case, presentation time corresponds to the actual output frame rendered. |
nanoTime |
Long: The system time when the frame was rendered. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# MediaCodec.OnFrameRenderedListener\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnFrameRenderedListener\n=======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/MediaCodec.OnFrameRenderedListener \"View this page in Java\") \n\n```\ninterface OnFrameRenderedListener\n```\n\n|-------------------------------------------------------|\n| [android.media.MediaCodec.OnFrameRenderedListener](#) |\n\nListener to be called when an output frame has rendered on the output surface\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onFrameRendered](#onFrameRendered(android.media.MediaCodec,%20kotlin.Long,%20kotlin.Long))`(`codec:` `[MediaCodec](/reference/kotlin/android/media/MediaCodec)`, `presentationTimeUs:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`, `nanoTime:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Called when an output frame has rendered on the output surface. |\n\nPublic methods\n--------------\n\n### onFrameRendered\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onFrameRendered(\n codec: MediaCodec, \n presentationTimeUs: Long, \n nanoTime: Long\n): Unit\n```\n\nCalled when an output frame has rendered on the output surface.\n\n**Note:** This callback is for informational purposes only: to get precise render timing samples, and can be significantly delayed and batched. Starting with Android [android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE](../os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE:kotlin.Int), a callback will always be received for each rendered frame providing the MediaCodec is still in the executing state when the callback is dispatched. Prior to Android [android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE](../os/Build.VERSION_CODES.html#UPSIDE_DOWN_CAKE:kotlin.Int), some frames may have been rendered even if there was no callback generated.\n\n| Parameters ||\n|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `codec` | [MediaCodec](/reference/kotlin/android/media/MediaCodec): the MediaCodec instance This value cannot be `null`. |\n| `presentationTimeUs` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): the presentation time (media time) of the frame rendered. This is usually the same as specified in [queueInputBuffer](/reference/kotlin/android/media/MediaCodec#queueInputBuffer(kotlin.Int,%20kotlin.Int,%20kotlin.Int,%20kotlin.Long,%20kotlin.Int)); however, some codecs may alter the media time by applying some time-based transformation, such as frame rate conversion. In that case, presentation time corresponds to the actual output frame rendered. |\n| `nanoTime` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): The system time when the frame was rendered. |\n\n**See Also**\n\n- [java.lang.System#nanoTime](../../java/lang/System.html#nanoTime())"]]