2012-07-05 125 views
-2

可能重複:
Video Streaming in vlcj視頻從服務器端傳輸到客戶端側

public class VlcTest 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); 
    } 

    NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:\\Program Files\\VideoLAN\\VLC"); 
    Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class); 

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

    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) { 
    String [] sb={":sout = #duplicate{dst=std{access=http,mux=ts,dst=127.0.0.1:5080}}"}; 
    return sb; 
    } 
} 

我想確認,可以在這個代碼能夠流從視頻服務器到客戶端。我想實現的流程是:

  1. 客戶端發送請求到服務器的流
  2. Server創建連接到客戶端發送的視頻在基於客戶端的IP地址和端口號的報文。
+0

昨天你不是問這個問題嗎? [視頻流在vlcj](http://stackoverflow.com/questions/11343523/video-streaming-in-vlcj) – 2012-07-06 21:28:34

回答

0

沒有這個代碼不會做你想要的。請參閱我的answer以瞭解原因。尤其是部分「StreamHttp.java部分的解釋」

相關問題