0

In my implementation I use for MediaCodec decoders to decode videos in a sequential order frame by frame and everything works fine. But if before starting the decoding process I play some media using MediaPlayer and TextureView (extended TextureView that I render on with GLES), the forth decoder won't act normal for example when the outputFormat changes it returns a wrong color-format for the codec while the first three decoders work normally. I know it's mostly hardware dependant but any thought would be appreciated specifically on the relationship it has with MediaPlayer.

p.s: I do release and clean up the MediaPlayer instance before starting decoding.

EDIT:

The device is Samsung Note3 and I'm playing back regular media. When it fails the behaviour stays even if I wait couple of minutes or if I force stop the activity and rerun it unless I restart the device. The expected color-format as you can see in following logs is "QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m".

Before failure:

...MediaEditor( 6837): [503] decoder0 output format changed: {height=720,   what=1869968451, color-format=2141391876, slice-height=736, crop-left=0, width=1280, crop-bottom=719, crop-top=0, mime=video/raw, stride=1280, crop-right=1279}
...MediaEditor( 6837): [503] decoder1 output format changed: {height=720, what=1869968451, color-format=2141391876, slice-height=736, crop-left=0, width=1280, crop-bottom=719, crop-top=0, mime=video/raw, stride=1280, crop-right=1279}
...MediaEditor( 6837): [503] decoder2 output format changed: {height=720, what=1869968451, color-format=2141391876, slice-height=736, crop-left=0, width=1280, crop-bottom=719, crop-top=0, mime=video/raw, stride=1280, crop-right=1279}
...MediaEditor( 6837): [503] decoder3 output format changed: {height=720, what=1869968451, color-format=2141391876, slice-height=736, crop-left=0, width=1280, crop-bottom=719, crop-top=0, mime=video/raw, stride=1280, crop-right=1279}

After failure:

...MediaEditor( 6837): [503] decoder0 output format changed: {height=720, what=1869968451, color-format=2141391876, slice-height=736, crop-left=0, width=1280, crop-bottom=719, crop-top=0, mime=video/raw, stride=1280, crop-right=1279}
...MediaEditor( 6837): [503] decoder1 output format changed: {height=720, what=1869968451, color-format=2141391876, slice-height=736, crop-left=0, width=1280, crop-bottom=719, crop-top=0, mime=video/raw, stride=1280, crop-right=1279}
...MediaEditor( 6837): [503] decoder2 output format changed: {height=720, what=1869968451, color-format=2141391876, slice-height=736, crop-left=0, width=1280, crop-bottom=719, crop-top=0, mime=video/raw, stride=1280, crop-right=1279}
...MediaEditor( 6837): [512] surface decoder0 given buffer 0 (size=1413120)
...MediaEditor( 6837): [512] surface decoder1 given buffer 0 (size=1413120)
...MediaEditor( 6837): [512] surface decoder2 given buffer 0 (size=1413120)
...MediaEditor( 6837): [503] decoder3 output format changed: {height=720, what=1869968451, color-format=19, slice-height=720, crop-left=0, width=1280, crop-bottom=719, crop-top=0, mime=video/raw, stride=1280, crop-right=1279}
...MediaEditor( 6837): [512] surface decoder0 given buffer 1 (size=1413120)
...MediaEditor( 6837): [512] surface decoder1 given buffer 1 (size=1413120)
...MediaEditor( 6837): [512] surface decoder2 given buffer 1 (size=1413120)
...MediaEditor( 6837): [512] surface decoder3 given buffer 0 (size=1382400)
feisal
  • 585
  • 1
  • 8
  • 20
  • Can you show some logs? What color-format values are you seeing? What device? I'm wondering if you're running out of hardware resources and it's falling back to something else. Are you playing back "secure" content? If you sleep for half a second between releasing the MediaPlayer and configure+starting the MediaCodec decoder, does the behavior change? – fadden Nov 12 '13 at 22:19
  • I edited the answer with the logs, if I'm running out of the hardware resources how can I manage that or free up the resources on GPU? – feisal Nov 14 '13 at 15:20
  • 1
    I was able to reproduce your results by modifying the `checkVideoFile()` method in `DecodeEditEncode` test to create four decoders before the test ran. I saw color-format=19 during the test, changed from 2141391876 without my modifications, but the test did pass. (This is on a Nexus 5 running 4.4, so it's not quite the same, but it's still a qcom SoC.) This seems to confirm the idea that a decoder resource isn't being released by MediaPlayer. Unfortunately I don't know an easy way to track it down. – fadden Nov 14 '13 at 20:52
  • Thanks a lot for following up. I really appreciate if you know any friend in MediaServer team, and get his opinion on it. – feisal Nov 14 '13 at 21:20
  • The test passed because what ever the decoder falls back to, still returns decoded buffers. But the problem is that, in my case I'm decoding to a surface and when it fails, it doesn't return the OnFrameAvailable callback though as you see in the above logs it looks like is still returning dequeueing decoded buffers. – feisal Nov 15 '13 at 15:04
  • fwiw, 2141391876 is OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar32m. see http://bigflake.com/mediacodec/ – FuzzyAmi Jul 12 '16 at 06:07

0 Answers0