Hello. I am trying to display the video stream from a drone in Unity. It looks like the way to do this in Unity is to use the Video Player component.
I have successfully made a test app where I can stream a video from a URL and display it in my scene.
The data I get from the drone is not a URL however. It arrives a a byte array. Here is the relevant code snippet.
// In DJIPluginActivity.java
public void onReceive(byte[ ] videoBuffer, int size) {
Log.d(TAG, "camera recv video data size: " + size);
}
Is there any way for me to take this data and create a URL from it that I can pass to the Video Player component in Unity? If so, how. If not, how would I go about displaying this video in Unity?
You would have to create a server that provides the data as a video URL. I’m assuming the byte[ ] is a stream from the drone (live footage) and not the whole video, otherwise just download the video (loop through the whole thing while writing the bytes to a file) and provide the file to Unity (the URL can point to a local file).
Yeah, the data is is a live stream, not a file we can download.
This is out of my area of expertise. Is there a lightweight and simple server that you can recommend that can run on Android and iOS? I imagine that this would be the only thing the server would do.