Comments (19)
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.
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.
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.
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.
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.
@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:
- 95% of the frames sent to the other participant are correct, however some are green or grey or has the local camera content.
- 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.
@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.
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.
Thanks alot!
from uvccamera.
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.
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.
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.
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.
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.
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.
@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.
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.
@tamasberesoebb really thanks.. more than three days to solve this problem 🤣🤣🤣
from uvccamera.
Thank you very much for sharing.
from uvccamera.
Related Issues (20)
- pthread_mutex_lock called on a destroyed mutex
- How to compile this code in Android Studio Flamingo | 2022.2.1
- A patch for USBMonitor.java to avoid crash in USB 3.0 HUB
- Working with FLIR Boson camera
- jpeg_read_scanlines crash
- java.lang.RuntimeException: Unable to start activity ComponentInfo : java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity HOT 1
- How to make zoom of texture ( input frames of camera) in UVCCameraTextureView ? HOT 1
- After multiple attempts to open the UVC camera, it fails to reopen. Assistance is requested HOT 2
- Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.serenegiant:common:2.12.5.
- The preview freezes when you press record on the Samsung a54 HOT 1
- MediaRecorder instead of MediaEncoder
- [Security] libjpeg-turbo used in this project is vulnerable
- Can't get started HOT 1
- Android11, RK3568, null pointer dereference HOT 2
- Permission pop-up giving illegal agruement exception in TargetSdk>27
- SQ 29 Camera does not display image HOT 1
- 有人知道如何解决4K以上画质得延迟问题吗?解决成功可以给予报酬。 HOT 1
- Android app crashing when using multiple .aar libraries
- Difference between ( 'Y', '8', ' ', ' ' ) and ('Y', '8', '0', '0') HOT 1
- Execution failed for task ':libuvc:ndkBuild'. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uvccamera.