VLCJ流视频开始时间
VLCJ stream video start time
我正在尝试使用 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);
但是没有效果
我错了
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();
}
我正在尝试使用 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);
但是没有效果
我错了
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();
}