【问题标题】:VLCJ stream video start timeVLCJ 流视频开始时间
【发布时间】:2018-05-08 20:45:51
【问题描述】:

我正在尝试使用 vlcj 从某一分钟开始播放视频

我所拥有的一切都很好

public static void main(String[] args) throws Exception {
    System.setProperty("VLC_PLUGIN_PATH", "C:\\Program Files\\VideoLAN\\VLC\\plugins");
    File vlcInstallPath = new File("C:\\Program Files\\VideoLAN\\VLC");
    NativeLibrary.addSearchPath(
            RuntimeUtil.getLibVlcLibraryName(), vlcInstallPath.getAbsolutePath());
    Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
    LibXUtil.initialise();

    String[] media = {"C:\\clips\\clip.mp4"};

    String options = ":sout=#transcode{vcodec=h264,vb=100,venc=x264{profile=baseline},fps=10,width=1920,height=1080,acodec=mp3,ab=24,channels=1,samplerate=44100}:http{mux=ffmpeg{mux=flv},dst=:8080/";
    MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(media);
    HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
    mediaPlayer.playMedia(media[0], options);
    Thread.currentThread().join();
}

但总是从头开始, 当我使用 VLC 媒体播放器启动流时。

我所期望的是,直播的时间一直在进行,每次我加入直播时,我都会跳到这个时间,但这并没有发生。 有什么方法可以实现吗?

如果没有,是否可以在某一分钟开始直播?

我试过了 mediaPlayer.setTime(100); 但是没有效果

【问题讨论】:

    标签: java networking stream vlcj


    【解决方案1】:

    我错了

    How to understand the difference between the two online video: RTSP and HTTP?

    public static void main(String[] args) throws Exception {
        System.setProperty("VLC_PLUGIN_PATH", "C:\\Program Files\\VideoLAN\\VLC\\plugins");
        File vlcInstallPath = new File("C:\\Program Files\\VideoLAN\\VLC");
        NativeLibrary.addSearchPath(
                RuntimeUtil.getLibVlcLibraryName(), vlcInstallPath.getAbsolutePath());
        Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
        LibXUtil.initialise();
    
        String[] media = {"C:\\clips\\clip.mp4"};
    
        //String options = ":sout=#transcode{vcodec=h264,vb=100,venc=x264{profile=baseline},fps=10,width=1920,height=1080,acodec=mp3,ab=24,channels=1,samplerate=44100}:http{mux=ffmpeg{mux=flv},dst=:8090/";
        String options = formatRtspStream("127.0.0.1",8080, "demo");//":sout=#transcode{vcodec=h264,vb=100,venc=x264{profile=baseline},fps=10,width=1920,height=1080,acodec=mp3,ab=24,channels=1,samplerate=44100}:rtp{sdp=rtsp://:8090/}";
        MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(media);
        HeadlessMediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
        mediaPlayer.playMedia(media[0],
                options,
                ":no-sout-rtp-sap",
                ":no-sout-standard-sap",
                ":sout-all",
                ":sout-keep"
        );
        Thread.currentThread().join();
    }
    
    private static String formatRtspStream(String serverAddress, int serverPort, String id) {
        StringBuilder sb = new StringBuilder(60);
        sb.append(":sout=#rtp{sdp=rtsp://@");
        sb.append(serverAddress);
        sb.append(':');
        sb.append(serverPort);
        sb.append('/');
        sb.append(id);
        sb.append("}");
        return sb.toString();
    }
    

    https://github.com/caprica/vlcj/blob/master/src/test/java/uk/co/caprica/vlcj/test/streaming/StreamRtsp.java

    【讨论】:

    • 你是怎么称呼这个的,我的意思是在你的本地主机中?
    猜你喜欢
    • 1970-01-01
    • 2021-01-24
    • 2023-04-10
    • 2013-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多