[vlc-devel] Re: Java APIs for VLC

Filippo Carone filippo at carone.org
Mon Apr 10 11:33:33 CEST 2006

Kuldipsingh Pabla ha scritto:
> Now, I have a question. If I want to do transcoding while playing a
> clip, how do I do it using your Java API? Do you have any samples? My
> intention is play a clip and transcode into an mpg4 file (from mpeg2).
> I'll greatly appreciate your help.

First of all update jvlc from
http://www.carone.org/publicsvn/jvlc/jvlc-trunk svn repository, since I
fixed a bug to make this work properly.

Here is the sample code:

public class VLC {

    public static void main(String args[]) {
        JVLC jvlc = new JVLC(args);
        jvlc.playlist.play(-1, null);
        try {
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block


As you can see, the JVLC class takes a String[] array, which contains
the cmd line. If you run it in this way:

java -Djava.library.path=. VLC myfile.avi --sout

it will transcode the myfile.avi file in a file.avi ogg file. Now focus
on these lines:

        try {
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block

These mean vlc will run for 10secs, since the JVLC object does not wait
for the playlist thread to end its tasks. If you use a GUI this problem
doesn't show up, since the JVLC object presumably has the same lifespan
of the main window.

This sample anyway shows that you can use JVLC with the same command
line of vlc expecting the same result.

Let me know if there are problems running it in this way,

This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html

More information about the vlc-devel mailing list