Xuggler and playing from live stream

2019-04-10 15:55发布

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?

2条回答
smile是对你的礼貌
2楼-- · 2019-04-10 16:26

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!!

查看更多
该账号已被封号
3楼-- · 2019-04-10 16:50

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!

查看更多
登录 后发表回答