Hello everybody,
I have a Linux machine having the VLC in a VoD setup mode.
Using the java bindings for gstreamer I was able to play the video
streams successfully. However I would like to seek into the video
stream. For example I would like to start to see the stream from a
tracked position (e.g. 0:23) until to the end.
I've tried the following code:
public static void main(String[] args) {
args = Gst.init("VoD player", args);
final PlayBinMediaPlayer player = new
PlayBinMediaPlayer("video",
Executors.newCachedThreadPool());
player.setURI(URI.create(args[0]));
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
VideoComponent vComp = new
VideoComponent();
player.setVideoSink(vComp.getElement());
JFrame frame = new JFrame("MyPlayer");
frame.getContentPane().add(vComp,
BorderLayout.CENTER);
frame.setPreferredSize(new
Dimension(400, 500));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
player.play();
long startNanos = 200000000000L;
long endNanos = 500000000000L;
boolean haveEnd = false;
Pipeline pipe = player.getPipeline();
pipe.getState();
int flags = SeekFlags.FLUSH |
SeekFlags.SEGMENT
| SeekFlags.ACCURATE;
if (haveEnd) {
pipe.seek(1.0, Format.TIME, flags, SeekType.SET,
startNanos,
SeekType.SET, endNanos);
} else {
pipe.seek(1.0, Format.TIME,
flags, SeekType.SET,
startNanos,
SeekType.NONE, -1);
}
pipe.play();
//
player.play();
}
});
Gst.main();
}
The problem is that the client establish a RTSP session with VLC
server, starts playing from the beginning and after 3-4 sec is
pausing. If I'm using the code fro playing a file form my local disk,
is seeking correctly.
What I'm doing wrong?
Thank you very much.
Thanks,
-Daniel