tôi đề nghị bạn để đi với VLCJ, bởi vì ngoài việc sống streaming video trực tuyến, bạn sẽ có được tất cả các tính năng của VLC media player có sẵn cho ứng dụng của bạn. Ngoài ra, nó có sẵn cho Linux, Windows và Mac. Nếu bạn có thể phát trực tuyến webcam của mình bằng VLC, thì bạn có thể làm tương tự với VLCJ.
Tham khảo VLCJ wiki page để biết chi tiết về cách sử dụng. Họ cung cấp nhiều ví dụ trong wiki. Dưới đây là một ví dụ về Http Streaming sử dụng VLCJ. Được sao chép từ các ví dụ 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 <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();
}
}
thử liên kết java với gstreamer: http://code.google.com/p/gstreamer-java/ –