How to record ipcamera in vlc..?

my code for stream ipcamera :

rtsp://10.10.10.3:554/nphMpeg4/g726-640x480 and save to test.asf

how record ipcamera using  *.*asf file...??? Please help me

 

 

GroG's picture

You said you wanted it in

You said you wanted it in Java so a quick search bring up this video :

Its an example of how to use VLCJ to play media,  The second "file" in the video would be your rtsp://...  url.

You will have to look up how to save the media using VLCJ.

Dedy_hidayat's picture

"Unable to load library 'libvlc' I am Using Windows 7 64 Bit..

 

package vlcj;
 
 
import com.sun.jna.Memory;
import com.sun.jna.NativeLibrary;
import java.nio.ByteBuffer;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import uk.co.caprica.vlcj.player.MediaPlayerFactory;
import uk.co.caprica.vlcj.player.direct.BufferFormat;
import uk.co.caprica.vlcj.player.direct.BufferFormatCallback;
import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer;
import uk.co.caprica.vlcj.player.direct.RenderCallback;
 
public class VLCTestPlayer implements RenderCallback, BufferFormatCallback {
 
protected MediaPlayerFactory mediaPlayerFactory;
 
protected DirectMediaPlayer mediaPlayer;
 
public static void main(final String[] args) {
    NativeLibrary.addSearchPath("libvlc","C:\\Program Files (x86)\\VideoLAN\\VLC");
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            VLCTestPlayer testplayer = new VLCTestPlayer(args);
        }
    });
}
 
private VLCTestPlayer(String[] args) {
 
    JFrame frame = new JFrame("vlcj Tutorial");
 
    mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--verbose=3");
 
    mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(this, this);
 
    String videoFile = "myVideo.mp4";
    boolean started = mediaPlayer.prepareMedia(videoFile);
 
    if (started)
        mediaPlayer.play();
    System.out.println("Video started: " + started + " from: " + videoFile);
 
    frame.setLocation(100, 100);
    frame.setSize(1050, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}
 
@Override
public BufferFormat getBufferFormat(int sourceWidth, int sourceHeight) {
    sourceWidth = sourceWidth / 1;
    sourceHeight = sourceHeight / 1;
    System.out.println("Got VideoFormat: " + sourceWidth + "x"
            + sourceHeight);
    BufferFormat format = new BufferFormat("RGBA", sourceWidth,
            sourceHeight, new int[] { sourceWidth * 4 },
            new int[] { sourceHeight });
 
    return format;
}
 
@Override
public void display(DirectMediaPlayer mediaPlayer, Memory[] nativeBuffers,
        BufferFormat bufferFormat) {
 
    ByteBuffer buffer = nativeBuffers[0].getByteBuffer(0,
            (int) bufferFormat.getWidth() * (int) bufferFormat.getHeight()
                    * 4);
    int pos = 4 * ((int) bufferFormat.getWidth()
            * (int) bufferFormat.getHeight() / 2 + (int) bufferFormat
            .getWidth() / 2) + 700;
    System.out.println("Got VideoFrame: " + buffer.get(pos) + ":"
            + buffer.get(pos + 1) + ":" + buffer.get(pos + 2) + ":"
            + buffer.get(pos + 3));
}
}
GroG's picture

You need to add a command

You need to add a command line parameter to java when it starts your class.  This tells where Java where it can look for required native files - such as libvlc.dll - find the file and add the path to this JVM argument.

java -Djava.library.path="C:\Program Files (x86)\VideoLAN\VLC;"

It would help to know if you are using Eclipse or some other IDE to debug.

Dedy_hidayat's picture

how do i run the command

 

how do i run the command
 
java-Djava.library.path = "C: \ Program Files (x86) \ VideoLAN \ VLC;"
 
I am confused .. :)
GroG's picture

Looking at the code you

Looking at the code you posted :

I see this line

NativeLibrary.addSearchPath("libvlc","C:\\Program Files (x86)\\VideoLAN\\VLC");

If libvlc.dll is not in "C:\\Program Files (x86)\\VideoLAN\\VLC" - then that is your first problem.

Another possible problem is you have Windows 64 operating system, but 32 bit Java, and a 64 bit VLC dll.  When you mix it like this it will not work.
Find the Java bitness this way

C:\>java -version
java version "1.6.0_33"

Java(TM) SE Runtime Environment (build 1.6.0_33-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)
 
As you can see I have a 64 bit JVM - is this the same on your system?
Dedy_hidayat's picture

what should I do to resolve e this?

my java version 64 Bit:

 

Java: 1.7.0_04; Java HotSpot(TM) 64-Bit Server VM 23.0-b21

System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)       

 

I think I did not mix the java version and Windows version.. 

am use java 64 bit and windows 64 bit.

 

i see libvlc.dll in my computer C:\\Program Files (x86)\\VideoLAN\\VLC

 

my error code :

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libvlc': The specified module could not be found.
 
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:194)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:283)
at com.sun.jna.Library$Handler.<init>(Library.java:142)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at rstp.VLCTestPlayer.main(VLCTestPlayer.java:29)
Java Result: 1
 
 
what should I do to resolve e this?
GroG's picture

Where is libvlc.dll on your

Where is libvlc.dll on your system?

Dedy_hidayat's picture

what should I do?

libvlc.dll and libvlccore.dll on C:\Program Files (x86)\VideoLAN\VLC..

if libvlc.dll I have found, what should I do?

 

Dedy_hidayat's picture

I expect an answer from you please help me

 

after am add vlcj-1.2.0.jar, jna.jar, platfrom.jar to netbeans the problem remains the same, 
 
 
run:
       _       _
__   _| | ___ (_)
\ \ / / |/ __|| |
 \ V /| | (__ | |
  \_/ |_|\___|/ | 1.2.0
            |__/
 
VLCJ is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
VLCJ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with VLCJ.  If not, see <http://www.gnu.org/licenses/>.
 
Copyright 2009, 2010, 2011 Caprica Software Limited.
 
Exception in thread "main" java.lang.RuntimeException: Failed to load the native library.
 
The error was "Unable to load library 'libvlc': The specified module could not be found.
".
 
The required native libraries are named "libvlc.dll" and "libvlccore.dll".
 
In the text below <libvlc-path> represents the name of the directory containing "libvlc.dll" and "libvlccore.dll".
 
There are a number of different ways to specify where to find the native libraries:
 1. Include NativeLibrary.addSearchPath("libvlc", "<libvlc-path>"); at the start of your application code.
 2. Include System.setProperty("jna.library.path", "<libvlc-path>"); at the start of your application code.
 3. Specify -Djna.library.path=<libvlc-path> on the command-line when starting your application.
 4. Add <libvlc-path> to the system search path (and reboot).
 
More information may be available in the log, specify -Dvlcj.log=DEBUG on the command-line when starting your application.
 
at uk.co.caprica.vlcj.binding.LibVlcFactory.create(LibVlcFactory.java:113)
at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:156)
at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:143)
at vlcj.SaveStream.main(SaveStream.java:9)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
 
 
I expect an answer from you please help me..
 

 

GroG's picture

Hmmm..  I'll have to try it

Hmmm..  I'll have to try it myself....  

Dedy_hidayat's picture

Thanks Friends

it's work..

the trouble at bit vlc version, this is my wrong..

your answer is true..

thanks grog