当前位置:  开发笔记 > 编程语言 > 正文

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

如何解决《服务器和客户端之间的实时视频流-使用Java》经验,为你挑选了1个好方法。

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

我一直在寻找Xuggler,JMF,Red5,VLCj之间的日子.我无法想象我应该从哪里开始,因为我刚接触编程中的媒体.

我应该从哪里开始的想法?

提前致谢



1> Jomoos..:

我建议您使用VLCJ,因为除了实时视频流之外,您还可以使用VLC媒体播放器的所有功能.此外,它适用于Linux,Windows和Mac.如果您可以使用VLC直播您的网络摄像头,那么您可以使用VLCJ进行相同操作.

有关如何使用它的详细信息,请参阅VLCJ wiki页面.他们在维基中提供了很多例子.以下是使用VLCJ的Http Streaming示例.复制自VLCJ示例.

/*
 * 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 .
 * 
 * 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.
 * 

* The client specifies an MRL of http://127.0.0.1:5555 */ 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(); } }

推荐阅读
手机用户2402852307
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有