Giter Site home page Giter Site logo

AppRTC about uvccamera HOT 19 CLOSED

saki4510t avatar saki4510t commented on August 14, 2024
AppRTC

from uvccamera.

Comments (19)

quanhua92 avatar quanhua92 commented on August 14, 2024 3

Hi @YasserMojahed ,
In my code, I use get the byte array data in addFrame function. Then, I use the opentok method "provideByteArrayFrame" to send the data. You need to find the similar method in your library to send the byte array.

from uvccamera.

quanhua92 avatar quanhua92 commented on August 14, 2024 2

Hi @shree-ram ,
I have used UVCCamera with OpenTOK successfully. Now, I can live stream video from usb camera.
Opentok is a platform for WebRTC. It is quite easy to use.
Here is my code to use UVCCamera with Opentok.
https://github.com/quanhua92/learn-opentok-android/tree/custom_webcam_capturer

from uvccamera.

sutogan4ik avatar sutogan4ik commented on August 14, 2024 2

Hello to all. I solved a similar problem, I decided to share my implementation
https://github.com/sutogan4ik/android-webrtc-usb-camera/blob/master/UsbCapturer.java

from uvccamera.

MelvinFMQ avatar MelvinFMQ commented on August 14, 2024 2

Hello to all. I solved a similar problem, I decided to share my implementation
https://github.com/sutogan4ik/android-webrtc-usb-camera/blob/master/UsbCapturer.java

@sutogan4ik webtrc does not have"onByteBufferFrameCaptured" anymore. I am facing difficulties figuring out how to implement for the new lib --> "onFrameCaptured"

from uvccamera.

netvandal avatar netvandal commented on August 14, 2024 2

To fix the red/blue flip problem replace in the OnConnect method the pixel format like this:

camera.setFrameCallback(UsbCapturer.this, UVCCamera.PIXEL_FORMAT_YUV420SP);

Full working code here:
https://gist.github.com/netvandal/5c12d94d1d43c33061594197e352b360

from uvccamera.

acrolink avatar acrolink commented on August 14, 2024 1

@MelvinFMQ I reverted to google-webrtc version 1.0.20849 since it has the onByteBufferFrameCaptured function. It works sort of. However there are two issues:

  1. 95% of the frames sent to the other participant are correct, however some are green or grey or has the local camera content.
  2. The app crashes after some 10-15 seconds.

I guess the correct way is the do it using the VideoFrame method however I have not found a way to convert the byte [] of the UVCCamera to a webrtc VideoFrame.

from uvccamera.

tamasberesoebb avatar tamasberesoebb commented on August 14, 2024 1

@Peter-St thanks for the tip!
I've solved the freezing issues like this:

           imageArray = new byte[frame.remaining()];
           frame.get(imageArray); //without this line only a green image was transferred
           long timestampNS = System.nanoTime();
           NV21Buffer buffer = new NV21Buffer(imageArray, UVCCamera.DEFAULT_PREVIEW_WIDTH, UVCCamera.DEFAULT_PREVIEW_HEIGHT, null);
           VideoFrame videoFrame = new VideoFrame(buffer, 0, timestampNS);
           capturerObserver.onFrameCaptured(videoFrame);

And just to summarise: yes it it possible to send over the usb webcam image over webrtc using these samples. Thanks for all the contributors!

from uvccamera.

saki4510t avatar saki4510t commented on August 14, 2024

Hi, open

I have been trying it from last year to early this year (and works at least until February) but I unfortunately interrupt it now. In my experience we need to modify deep inside of the WebRTC library(libjingle) to use external camera but as you know it is sometimes dynamically changed... I don't have enough time now to keep update for those changes.
The way to do so is implementing to get video frames from external library and pass them to libjingle instead of usual internal camera. At least on February, it is in VideoCaptureAndroid.java although I'm not sure it is still available now.

saki

from uvccamera.

shree-ram avatar shree-ram commented on August 14, 2024

Thanks alot!

from uvccamera.

YasserMojahed avatar YasserMojahed commented on August 14, 2024

Hi @quanhua92
Can I stream UVC to webrtc using this lib: compile 'io.pristine:libjingle:11139@aar' instead of Opentok?
In my case, I cannot customize VideoCapturerAndroid class.
thanks for helping ..

from uvccamera.

tamasberesoebb avatar tamasberesoebb commented on August 14, 2024

I also would like to combine this UVC Camera library with a WebRTC one.

Hello to all. I solved a similar problem, I decided to share my implementation
https://github.com/sutogan4ik/android-webrtc-usb-camera/blob/master/UsbCapturer.java

using this code, and a lot of googling, I've managed to upgrade to the newest version of webrtc, and transfer exactly 1 frame of a usb webcam image to a remote machine 🥇
After 1 frame it just stops.

@acrolink
Refactoring from onByteBufferFrameCaptured to onFrameCaptured:

            imageArray = new byte[frame.remaining()];
            frame.get(imageArray);
            imageTime = System.currentTimeMillis();
            mNV21Buffer = new NV21Buffer(imageArray, UVCCamera.DEFAULT_PREVIEW_WIDTH, UVCCamera.DEFAULT_PREVIEW_HEIGHT, null);
            mVideoFrame = new VideoFrame(mNV21Buffer, 0, imageTime);
            capturerObserver.onFrameCaptured(mVideoFrame);

This flips the blue and the red channels somehow, but I'm more worried right now about the stream freezing. I've been working on this for most of this week, and will continue next week.

from uvccamera.

acrolink avatar acrolink commented on August 14, 2024

This flips the blue and the red channels somehow, but I'm more worried right now about the stream freezing.

Does it freeze?

from uvccamera.

tamasberesoebb avatar tamasberesoebb commented on August 14, 2024

This flips the blue and the red channels somehow, but I'm more worried right now about the stream freezing.

Does it freeze?

Yes. The first frame is shown on the remote side, so 1 frame get's transferred over webrtc, and then it stops. The usb camera image on the local phone does not stop, nor does the remote device's camera feed.

from uvccamera.

Peter-St avatar Peter-St commented on August 14, 2024

Hello,

I got this answer from the WebRTC Forum about including extetnal frames:

long timestampNS = TimeUnit.MILLISECONDS.toNanos(SystemClock.elapsedRealtime());
android.util.Size size = camera.getCurrentVideoResolution();
NV21Buffer buffer = new NV21Buffer(bytes, size.getWidth(), size.getHeight(), null);
VideoFrame videoFrame = new VideoFrame(buffer, 0, timestampNS);
capturerObserver.onFrameCaptured(videoFrame);

About the freeze of the webrtc stream, I think your sended frames were not valid NV21, because I faced some similar freezing on converting Mjpeg to NV21 with crap frames during the conversation.

So far,

Peter

from uvccamera.

acrolink avatar acrolink commented on August 14, 2024

frame.get(imageArray); is that what you were missing? If I knew you missed that I could have told you long ago 👍 The important thing now, is the received video at the other end (by the other peer) smoothness without some bad frames once in a while? is it continually good?

If so, could you tell us which camera are you using / Android version / device ?

from uvccamera.

tamasberesoebb avatar tamasberesoebb commented on August 14, 2024

@acrolink it looks fine. 720p 30fps
It looks like, the problem I had in the end was wrong timestamps:
System.currentTimeMillis();
vs.
System.nanoTime();
VideofFrame needs a timestamp in nanoseconds.
I'm testing using a Samsung S10 newest updates and a Microsoft LifeCam HD-3000

from uvccamera.

Jinul avatar Jinul commented on August 14, 2024

This flips the blue and the red channels somehow, but I'm more worried right now about the stream freezing. I've been working on this for most of this week and will continue next week.

Hi @tamasberesoebb, I managed to fetch the feed using this code but it seems the colors are screwed up. How did you fix it, any suggestion?

from uvccamera.

Haemaru avatar Haemaru commented on August 14, 2024

@tamasberesoebb really thanks.. more than three days to solve this problem 🤣🤣🤣

from uvccamera.

acrolink avatar acrolink commented on August 14, 2024

@netvandal

Thank you very much for sharing.

from uvccamera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.