I have developed a live raw H.264 stream receiver-cum-player. I implemented it using Android's MediaCodec API. Video is rendered to the Surface obtained from a TextureView.
The program can successfully receive and play video, however, I am observing serious color banding with the video playback in color gradient areas.
Some more observations:
- The target Android device is a PC running on Android-x86-6.0.
- The default video player which comes with Android-x86, "Video player", also exhibits this issue when I play a video file with it (local playback).
- Third party video players, like Kodi & VLC for Android, does not exhibit this issue when I do local playback.
- I have used the Miracast protocol to capture video playback on my app on my phone (which is different from the aforementioned target device) to be displayed on a Miracast-enabled TV, and I do not see this color banding issue.
I have also tried to add dithering to cover this issue, but somehow the code for it does not seem to work. The following code was added in the onCreate() callback function of the main activity.
...
decorView.getBackground().setDither(true);
getWindow().setFormat(PixelFormat.RGBA_8888);
...
The TextureView on which the video is rendered is also loaded using Fragment.
I am at a lost at what could be the problem. Does the issue arrise because I used the output Surface rendering method? Is it because I load the TextureView using Fragment? Or is there a problem with my decoder implementation? Or is it something else?
Someone, please help. Thank you in advance.