[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);
        System.out.println(jvlc.playlist.itemsCount());
        jvlc.playlist.play(-1, null);
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println(".END.");
    }

}

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
"#transcode{vcodec=mp4v,vb=$bitrate,scale=1,acodec=mpga,ab=192,channels=2}:duplicate{dst=std{access=file,mux=ogg,dst='file.avi'}}"

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

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

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,
cheers,
filippo

-- 
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