Recently I've encountered a strange problem on Android 5.0.2 (API 21). My application is using SurfaceTexture to display video. Playback mechanics are mostly based on google/grafika's CameraCaptureAvtivity, but the video source is decoded .mp4 movie file instead of camera. The application worked just fine until I ran it on Galaxy S6 with Android 5.0.2 (I successfully used devices with 4.4.2 and 4.4.4 before that). The problem is that each time I try to recieve timestamp from SurfaceTexture with getTimestamp()
, the method returns 0, though playback is fine. On the other devices I've mentioned before the timestamp was correct.
Can someone tell me if this might be Android bug? Is there any way to work it around?
Asked
Active
Viewed 924 times
5

Krzysztof Kansy
- 305
- 2
- 13
-
Is it always zero, or do you get one zero and then it goes back to returning reasonable values? I used to see one frame with a zero timestamp after toggling the power off and on, but didn't have a chance to track it down. You can see a reference to it in https://github.com/google/grafika/blob/master/src/com/android/grafika/TextureMovieEncoder.java#L204 . – fadden May 27 '15 at 16:22
-
@fadden You're right, situation you're describing happens to me on 4.4.2 and 4.4.4, and I can handle it with no problems. Unfortunately, on Android 5.0.2 timestamp I'm getting from getTimestamp() is always zero during the whole playback. I'm also using TextureMovieEncoder you mentioned for encoding video to file, so I need this timestamp to be valid. – Krzysztof Kansy May 28 '15 at 07:26
-
Weird. Unfortunately I'm no longer in a position to investigate. Might be worth filing a bug on http://b.android.com/ . – fadden May 28 '15 at 16:54
-
As far as I can tell, MediaPlayer does still properly set the timestamp, but MediaCodec stopped in 5.0.2. Not much info, I know. – Mog Jul 21 '15 at 09:35
-
@Mog I didn't notice any other bugs with decoding other then this on 5.0.2 (I'm not even really sure if this would be MediaDecoder problem). As of MediaPlayer, I'm not familiar with it, my project does not use it because of some more sophisticated requirements. I filled a bug as fadden suggested and worked this around in the end. – Krzysztof Kansy Jul 21 '15 at 14:07
-
Hi, how tit you please worked this around? Is there a way to add timestamp manually to SurfaceTexture? I found this to be problem for me in one project... – kvgr Oct 22 '15 at 13:57
-
@kvgr If I recall it correctly, the timestamp was used while encoding displayed video. So instead of using the bugged timestamp from SurfaceTexture, I was continuously storing timestamps from decoder's MediaCodec.BufferInfo. They were used in encoder eventually. I hope this helps. – Krzysztof Kansy Oct 23 '15 at 06:36