Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VideoView flickering issue

I'm facing weird issue of flickering using VideoView. When activity starts, it causes minor flicker of fraction for a second. Then, video starts. It shows 2 black lines on the top and the bottom of the video. See the snap-shot below.

check snap shot

I have tested my application on 2 devices

1) Samsung n-8000(Tablet)

2) Lenovo a-800

video.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="#ffffff"
 android:gravity="center">

 <VideoView 
    android:id="@+id/vvSplash"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="#00ffffff">
</VideoView>

</LinearLayout>

Activity code:

private VideoView vd;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.video);
    vd = (VideoView) findViewById(R.id.vvSplash);
    playVideo();
}

private void playVideo() {
    Uri uri = Uri.parse("android.resource://" + getPackageName() +"/"+ R.raw.intro);
    vd.setVideoURI(uri);
    vd.setMediaController(null);
    vd.start();     
}

Any help would be appreciated. Thank you.

like image 993
TheFlash Avatar asked Jul 11 '13 07:07

TheFlash


People also ask

Why is my video footage flickering?

Flickering in video and film is a common problem resulting from certain frame rate and shutter speed combinations under artificial lighting. This article gives an overview of why this happens, along with recommending settings for minimizing the chances of this happening in the first place.

Why is my slo mo flickering?

The frequency of each video frame is far higher than the frequency of such lights. As a result, some frames of the videos are shot when the light is on while others are shot when the light is off. This is what causes flickering or ripples to appear in videos.


2 Answers

As ridiculous as it sounds, but the answer is here:

  • VideoView inside fragment causes black screen flicking
  • SurfaceView flashes black on load

I repeat the solution, kudos to those who found out:

<SurfaceView
    android:layout_width="0px"
    android:layout_height="0px"
    android:visibility="gone" />

It is VERY IMPORTANT that you add the surface view to the root view in your activity, not the immediate parent. Otherwise it won't work.

like image 126
Oliver Hausler Avatar answered Oct 20 '22 22:10

Oliver Hausler


i also faced same problem but solved it by changing layout parameter of videoview from wrap content to match parent . Also you need to remove the background property of video view from XML. I hope it will work for you

like image 2
Shakeeb Ayaz Avatar answered Oct 20 '22 22:10

Shakeeb Ayaz