简体   繁体   中英

Xuggler and playing from live stream

We're currently busy with a project in which we are trying to play a video file in a window from a live stream in Java. We've already managed to capture the stream via a Socket object using an InputStreamReader.

The next step is using an existing library (Xuggler) or code to decode this stream and display the contents (video) in a simple window.

The stream originates from the Parrot AR Drone 2.0 via IP address 192.168.1.1:5555. That's where we got stuck. The code we're trying to use is the DecodeandPlayVideo example found here:

https://github.com/xuggle/xuggle-xuggler/blob/master/src/com/xuggle/xuggler/demos/DecodeAndPlayVideo.java

Now it should be possible to use this with an inputstream but it should of course be in the right format. Is there some way you can help us do this?

Oke we solved the problem:

First we make a TCP connection to the drone:

try
    {
        socket_video_tcp = new Socket();
        socket_video_tcp.connect(new InetSocketAddress(commandSender.droneInetAddress, commandSender.VIDEO_PORT));
    }

Our class is Runnable what means that we also have a method run() In this method we send a video_enable command and we also disable the dynamic video bitrate by sending this command: video:bitrate_ctrl_mode 0;

public void run()
{
    commandSender.sendConfigCommand("VIDEO_ENABLE");
    commandSender.sendConfigCommand("VIDEOBITRATE");

    decode();
}

Our decode() method can be found here: https://github.com/xuggle/xuggle-xuggler/blob/master/src/com/xuggle/xuggler/demos/DecodeAndPlayVideo.java

In this decode method we have changed this:

 if (container.open(filename, IContainer.Type.READ, null) < 0)

To this:

if (container.open(socket_video_tcp.getInputStream(), null) < 0)

That's all!!

Copied from Edit in question:

Today we solved this problem. We tried before to load the socket connection into the Icontainer.open with socketconnection.getInputStream . The result was 0 streams. After some small adjustments the result is 1 stream and we can see the live video from the drone on screen!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM