-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Issue description
When removing the surface from the SimpleExoPlayer and after some time re-adding it a lot of "droppedFrames" messages are triggered. This cause quite some delay before the video playback is continued (while sound is normally playing)
This is cause by a wrong translation of timestamps:
When the MediaCodecRenderer doesn't have a codec it calls skipToKeyframeBefore with positionUs. This will call skipToKeyframeBefore on the stream. The stream expects the periodPositionUs but the used position the rendererPositionUs. In simple cases this can be adjusted using RENDERER_TIMESTAMP_OFFSET_US, but in other cases the offset can be a more variable value and it is not possible to adjust it without MediaPeriodHolder (which is not accessible in the MediaCodecRenderer. Because the seek fails, the renderer will try to decode all the frames as soon as an output is available again (Surface). As the delay is too high (>30 ms) the frames will be dropped.
Reproduction steps
Instantiate a SimpleExoPlayer (ExoPlayerFactory.newInstance). Clear surface but let video playback continue. Re-add a surface.
Link to test content
http://html5demos.com/assets/dizzy.mp4 (it's easier with longer videos to get some time for a larger time gap -> frames that are dropped)
Version of ExoPlayer being used
r2.3.0
Device(s) and version(s) of Android being used
Tested on PixelXL (7.1.1) and OnePlus 2 (6.0.1)
A full bug report captured from the device
D/EventLogger: videoDecoderInitialized [0.72, OMX.qcom.video.decoder.avc]
D/EventLogger: videoFormatChanged [0.72, id=2, mimeType=video/avc, res=480x360]
D/EventLogger: videoDecoderInitialized [15.12, OMX.qcom.video.decoder.avc]
D/EventLogger: droppedFrames [15.42, 50]
D/EventLogger: droppedFrames [15.61, 50]
D/EventLogger: droppedFrames [15.84, 50]
D/EventLogger: droppedFrames [16.08, 50]
D/EventLogger: droppedFrames [16.30, 50]
D/EventLogger: droppedFrames [16.52, 50]
D/EventLogger: droppedFrames [16.76, 50]
D/EventLogger: droppedFrames [16.99, 50]
D/EventLogger: droppedFrames [26.28, 48]