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

这篇博客建议初学者使用VLCJ库来实现实时视频流传输,特别是从服务器上的多个网络摄像头到客户端应用。VLCJ不仅支持直播,还提供了VLC媒体播放器的所有功能,并兼容Linux、Windows和Mac。博客中提供了一个使用VLCJ进行HTTP流媒体传输的示例代码。
摘要由CSDN通过智能技术生成

this is part of a project I am working on. I have two desktop java application , one runs on the server (which has real IP), and the other is the client. I just want to stream a live video from a webcam connected to the server application , and play it on the client application. I want to do this streaming from more than one camera.

I have been looking searching for days between Xuggler, JMF, Red5, VLCj. I just can't figure from where I should start as I am new to dealing with media in programming.

Any ideas from where I should start with this ?

Thanks in advance

解决方案

I suggest you to go with VLCJ, because in addition to live video streaming, you get all features of VLC media player available to your application. Also, it is available for Linux,Windows, and Mac. If you can live stream your webcam with VLC, then you can do the same with VLCJ.

Refer VLCJ wiki page for details on how to use it. They provided many examples in the wiki. Here is an example of Http Streaming using VLCJ. Copied from VLCJ examples.

/*

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

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值