twilio / video-quickstart-android

Twilio Video Quickstart for Android
MIT License
211 stars 160 forks source link

Issue in streaming Video in CustomVideoCapture Example #202

Closed BdeDev closed 6 years ago

BdeDev commented 6 years ago

Hey @aaalaniz i want to stream a video with twillio ,but i am unable to do so,with the Help of Your Custom Video Capture Example i successfully stream the UI elements ,but the Video is showing Black on Renderer Side. I only want to show the Video

aaalaniz commented 6 years ago

Hey @BdeDev

Can you share some code snippets or maybe a project I could look at? Are you trying to share ViewCapturer with a room?

Thanks!

BdeDev commented 6 years ago

Hey @aaalaniz ,thanks for your reply, Yes, I am trying to share ViewCapturer with a Room,but firstly i test it on your given samples in Custom Video Capture ,All the UI elements are Render Except the Video,The Code is Same as of Your Sample of CustomVideoCapture i only added a Video View and play a Video Through it but when i render it, all the UI elements are shown Except the Video View Which is Showing Black Screen As My requirement is only to Render the Video View So, can you please provide me a class like ViewCapture which can help me to capture the Video

aaalaniz commented 6 years ago

Hey @BdeDev

Please share a project or code snippets so I can investigate the issue further.

Thanks!

BdeDev commented 6 years ago

Hey @aaalaniz

This one is the layout from your sample the layout name is activity_custom_capturer.xml i have only add a video video in it @+id/videoVV

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">

<LinearLayout
    android:id="@+id/captured_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:background="@android:color/white"
    android:orientation="vertical">

    <Chronometer
        android:id="@+id/timer_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="8dp" />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="8dp" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="8dp" />

    <VideoView
        android:id="@+id/videoVV"
        android:layout_width="match_parent"
        android:layout_height="100dp" />
</LinearLayout>

<com.twilio.video.VideoView
    android:id="@+id/video_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1" />

============================================== Now this is my CustomCapturerVideoActivity public class CustomCapturerVideoActivity extends Activity { private LinearLayout capturedView; private VideoView videoView; private Chronometer timerView; private LocalVideoTrack localVideoTrack; private android.widget.VideoView videoVV;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom_capturer);

    capturedView = (LinearLayout) findViewById(R.id.captured_view);
    videoVV = (android.widget.VideoView) findViewById(R.id.videoVV);

    videoView = (VideoView) findViewById(R.id.video_view);
    timerView = (Chronometer) findViewById(R.id.timer_view);
    timerView.start();

    Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.test);
    videoVV.setVideoURI(uri);
    videoVV.start();

    // Once added we should see our linear layout rendered live below
    localVideoTrack = LocalVideoTrack.create(this, true, new ViewCapturer(capturedView));

    localVideoTrack.addRenderer(videoView);
}

@Override
protected void onDestroy() {
    localVideoTrack.removeRenderer(videoView);
    localVideoTrack.release();
    localVideoTrack = null;
    timerView.stop();
    super.onDestroy();
}

}

See in this way i have play a video in video view but when i render the localVideoTrack the other UI elements show perfectly but the video player shows only black screen

aaalaniz commented 6 years ago

Hey @BdeDev

This looks like a potential problem between our VideoView and the android.widget.VideoView. I will investigate further. In the meantime can you try using an experimental VideoView refereneced in #149 ?

You can find the gist here:

https://gist.github.com/aaalaniz/bfbc4891c98ef3b23558ff2260cbcc8e

This VideoView is backed by a TextureView instead of a SurfaceView. A TextureView behaves like a normal view, so it may not cause the problems you are seeing. Let me know if it works.

Thanks!

BdeDev commented 6 years ago

Hey @aaalaniz

Thank you for your reply I have tried to render the video by your VideoTextureView But the issue remains the same

But if you mean by using VideoTextureView in place of Android Video View Can You Please Explain me How to Play a normal Video through this VideoTectureView as i am simply playing the video in android video view by adding it in raw file
the Code is Here:

    Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.test);
    videoVV.setVideoURI(uri);
    videoVV.start();

So, can you please suggest me how to use it like a normal android Video View Thanks!

aaalaniz commented 6 years ago

Hey @BdeDev

Our VideoView does not render video from a URI like android.widget.VideoView. Our VideoView is meant to render I420 frames from a VideoTrack or LocalVideoTrack. Let me know if I can clarify anything.

Thanks!

BdeDev commented 6 years ago

Hey @aaalaniz

Thanks for your reply,This means you are saying that it is not possible to render a Android Video View which is playing in an layout ,Twilio video only render the Twilio's Video View

I also want to tell you that i have used the same which you are talking about i have stream a video by your Video texture view but when i render it in the rendering side then also issues remains the same can you please check that issue for me Steps are 1.Add Video Texture in a layout view and stream through it 2.Add local Video Track Like in your Custom Video Capture exaple 3.Render it with the Twilio video view

As the issue remains same that time also as i am using the same Video Texture view that you have recommended

aaalaniz commented 6 years ago

Hey @BdeDev

Can you post a screenshot of the issue? I think that would be really helpful to diagnose what is happening.

Thanks!

BdeDev commented 6 years ago

Hey @aaalaniz

Thank you for your reply, i can send you screen shot But, I want to tell you that the Screen output is only the Black Screen on the render side I can explain you the full scenario 1.I Stream through your Video Texture view in a linear layout 2.Then in i add the Local Video Track as like same given in your Custom Video Capture 3.I render the video on the render side 4.Both the participants were added and the video is also subscribed 5.But the Render side shows the black screen

This problem is only is with the custom video capture flow ,When i do it with the Screen capture as given in your sample the Render side runs very Well.

Hope you understands the problem ,Please Share your requirements if any Thank you

aaalaniz commented 6 years ago

Hey @BdeDev

I think I understand your problem. I will investigate today.

aaalaniz commented 6 years ago

Hey @BdeDev

I am not able to reproduce your issue. I was able to create a video track with ViewCapturer and share with all participants of a Room. However, I'm not sure I understand your problem completely. Please post a screenshot so I can investigate further.

Thanks!

BdeDev commented 6 years ago

Hello @aaalaniz Apologizes for the late reply,

This is the Screen shot of where i am creating a local video track device-2017-12-11-125524

And this is the render side screenshot_1512977087

I think i am doing mistake in rendering the view Please share your Code which you had tried with the ViewCapturer to create Local tack and to Render Local track Hope it can help me to solve the issue

aaalaniz commented 6 years ago

Hey @BdeDev

What code is being executed on the renderer side? Can you provide a Room SID? You can get a room SID from the Room object using getSid().

Thanks!

BdeDev commented 6 years ago

Hey @aaalaniz Apologizes for the late Reply

i use this code on the render side to render the stream @Override public void onVideoTrackSubscribed(RemoteParticipant remoteParticipant, RemoteVideoTrackPublication remoteVideoTrackPublication, RemoteVideoTrack remoteVideoTrack) { showToast("onVideoTrackSubscribed");

            remoteVideoTrack.addRenderer(video_view);

        }

============== Xml Code <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent">

<com.twilio.video.VideoView
    android:id="@+id/video_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

=========== And the Room SID is RMea3763b920168d713350280ef7486031

Hope it may help you

please ask for more if you required anything

Thanks!

aaalaniz commented 6 years ago

Hey @BdeDev

I'm not sure if this is the exact issue, but it looks like you are using the same identity test66 for each participant. Can you try using a unique identity for each participant?

Thanks!

BdeDev commented 6 years ago

Hey @aaalaniz thanks for the reply its my mistake actually that i had not added the streaming application in the room this is the new room SID RM78d7cb9282fd65fa89653ade3bfecdb7

Here i use different identity as you told

Thanks!

aaalaniz commented 6 years ago

Hey @BdeDev

Based on what I see, I think you have two video tracks being subscribed to, but only one view to render those tracks. Can you try creating two VideoView instances for each track you are sharing? I think the problem is that you are rendering both tracks to the same view which is causing problems.

aaalaniz commented 6 years ago

Closing due to inactivity. Please reopen if you have any further inquiries @BdeDev

Thanks!

AnkanDey commented 6 years ago

Hello @aaalaniz.

I am facing the same issue here. I have downloaded the project from git, and just added a videoview in the XML in CustomVideoCapturer project module. Everything showing in the local videoview(@+id/video_view)(eg. Checkbox, Chronometer) but the video(@+id/video) showing black.

My XML looks like below.

<LinearLayout android:id="@+id/captured_view" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:background="@android:color/white" android:orientation="vertical">

<Chronometer
    android:id="@+id/timer_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="8dp" />

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="8dp" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="8dp" />

<VideoView
    android:id="@+id/video"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<com.twilio.video.VideoView android:id="@+id/video_view" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" />

Please help me.

Drashti-Gabani commented 2 years ago

I am also facing same issue, I have used ExoPlayer in my application for video steaming. video frames are not being rendered at connected room participants using CustomVideoCapture example. it shows blank screen only for video view, rest all UI elements are rendering correctly. is there any way to fix this issue?