Stay organized with collections
Save and categorize content based on your preferences.
public
static
interface
MediaCodec.OnFrameRenderedListener
android.media.MediaCodec.OnFrameRenderedListener
|
Listener to be called when an output frame has rendered on the output surface
Summary
Public methods |
abstract
void
|
onFrameRendered(MediaCodec codec, long presentationTimeUs, long nanoTime)
Called when an output frame has rendered on the output surface.
|
Public methods
public abstract void onFrameRendered (MediaCodec codec,
long presentationTimeUs,
long nanoTime)
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 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
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 MediaCodec.queueInputBuffer(int, int, int, long, 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. |
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](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nMediaCodec.OnFrameRenderedListener\n==================================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/media/MediaCodec.OnFrameRenderedListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nMediaCodec.OnFrameRenderedListener\n`\n\n\n`\n\n\n`\n\n|--------------------------------------------------|\n| android.media.MediaCodec.OnFrameRenderedListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nListener to be called when an output frame has rendered on the output surface \n**See also:**\n\n- [MediaCodec.setOnFrameRenderedListener(OnFrameRenderedListener, Handler)](/reference/android/media/MediaCodec#setOnFrameRenderedListener(android.media.MediaCodec.OnFrameRenderedListener,%20android.os.Handler))\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onFrameRendered](/reference/android/media/MediaCodec.OnFrameRenderedListener#onFrameRendered(android.media.MediaCodec,%20long,%20long))`(`[MediaCodec](/reference/android/media/MediaCodec)` codec, long presentationTimeUs, long nanoTime) ` Called when an output frame has rendered on the output surface. |\n\nPublic methods\n--------------\n\n### onFrameRendered\n\nAdded in [API level 23](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onFrameRendered (MediaCodec codec, \n long presentationTimeUs, \n long nanoTime)\n```\n\nCalled when an output frame has rendered on the output surface.\n\n\n**Note:** This callback is for informational purposes only: to get precise\nrender timing samples, and can be significantly delayed and batched. Starting with\nAndroid [Build.VERSION_CODES.UPSIDE_DOWN_CAKE](/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE), a callback will always\nbe received for each rendered frame providing the MediaCodec is still in the executing\nstate when the callback is dispatched. Prior to Android\n[Build.VERSION_CODES.UPSIDE_DOWN_CAKE](/reference/android/os/Build.VERSION_CODES#UPSIDE_DOWN_CAKE), some frames may have been\nrendered even if there was no callback generated.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `codec` | `MediaCodec`: the MediaCodec instance This value cannot be `null`. \u003cbr /\u003e |\n| `presentationTimeUs` | `long`: the presentation time (media time) of the frame rendered. This is usually the same as specified in [MediaCodec.queueInputBuffer(int, int, int, long, int)](/reference/android/media/MediaCodec#queueInputBuffer(int,%20int,%20int,%20long,%20int)); 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. \u003cbr /\u003e |\n| `nanoTime` | `long`: The system time when the frame was rendered. \u003cbr /\u003e |\n\n**See also:**\n\n- [System.nanoTime()](/reference/java/lang/System#nanoTime())"]]