Xuggler和现场直播 [英] Xuggler and playing from live stream

查看:200
本文介绍了Xuggler和现场直播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正忙于一个项目,在该项目中,我们尝试在Java的实时流中播放视频文件。我们已经设法使用InputStreamReader通过Socket对象捕获流。

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.

下一步是使用现有的库(Xuggler)或代码来解码此流和在一个简单的窗口中显示内容(视频)。

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

该流源自Parrot AR Drone 2.0,通过IP地址192.168.1.1:5555。
这就是我们陷入困境的地方。我们尝试使用的代码是这里找到的DecodeandPlayVideo示例:

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?

推荐答案

我们解决了这个问题:

首先我们与无人机建立TCP连接:

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));
    }

我们的类是Runnable意味着我们还有一个方法run()
在此方法中,我们发送video_enable命令,我们还通过发送以下命令禁用动态视频比特率:video:bitrate_ctrl_mode 0;

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();
}

我们的decode()方法可以在这里找到: https://github.com/xuggle/xuggle-xuggler /blob/master/src/com/xuggle/xuggler/demos/DecodeAndPlayVideo.java

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)

对此:

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

这就是!!

这篇关于Xuggler和现场直播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆