首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >服务器和客户端之间的实时视频流-使用Java

服务器和客户端之间的实时视频流-使用Java
EN

Stack Overflow用户
提问于 2011-12-03 22:23:03
回答 1查看 29.6K关注 0票数 9

这是我正在做的一个项目的一部分。我有两个桌面java应用程序,一个运行在服务器上(它有真正的IP),另一个是客户端。我只想从连接到服务器应用程序的摄像头流式传输实时视频,并在客户端应用程序上播放它。我想要从多个摄像头进行此流媒体。

我已经在Xuggler,Red5,VLCj之间寻找了几天的搜索。我只是不知道我应该从哪里开始,因为我是编程中与媒体打交道的新手。

有什么想法我应该从哪里开始呢?

提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-04 02:05:15

我建议你使用VLCJ,因为除了实时视频流之外,你的应用程序还可以使用VLC媒体播放器的所有功能。此外,它还可用于Linux、Windows和Mac。如果你可以用VLC直播你的摄像头,那么你也可以用VLCJ来做同样的事情。

具体使用方法请参考VLCJ wiki page。他们在wiki中提供了许多示例。以下是使用VLCJ的Http流的示例。从VLCJ示例中复制。

代码语言:javascript
复制
/*
 * This file is part of VLCJ.
 *
 * VLCJ is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VLCJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VLCJ.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2009, 2010, 2011 Caprica Software Limited.
 */

package uk.co.caprica.vlcj.test.streaming;

import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.headless.HeadlessMediaPlayer;
import uk.co.caprica.vlcj.test.VlcjTest;

/**
 * An example of how to stream a media file over HTTP.
 * <p>
 * The client specifies an MRL of <code>http://127.0.0.1:5555</code>
 */
public class StreamHttp extends VlcjTest {

  public static void main(String[] args) throws Exception {
    if(args.length != 1) {
      System.out.println("Specify a single MRL to stream");
      System.exit(1);
    }

    String media = args[0];
    String options = formatHttpStream("127.0.0.1", 5555);

    System.out.println("Streaming '" + media + "' to '" + options + "'");

    MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(args);
    HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
    mediaPlayer.playMedia(media, options);

    // Don't exit
    Thread.currentThread().join();
  }

  private static String formatHttpStream(String serverAddress, int serverPort) {
    StringBuilder sb = new StringBuilder(60);
    sb.append(":sout=#duplicate{dst=std{access=http,mux=ts,");
    sb.append("dst=");
    sb.append(serverAddress);
    sb.append(':');
    sb.append(serverPort);
    sb.append("}}");
    return sb.toString();
  }
}
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8368300

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档