/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apps.user.gui;
 
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import java.awt.BorderLayout;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
 
 
/**
 *
 * @author Dedy
 */
public class CctvUser extends javax.swing.JFrame {
     private final EmbeddedMediaPlayerComponent mediaPlayerComponent;
 
    /**
     * Creates new form CctvUser
     */
    public CctvUser() {
        JFrame frame = new JFrame("Closed Circuit Television (CCTV)"); 
        frame.setIconImage(new javax.swing.ImageIcon(getClass().
        getResource("/apps/user/image/cctv.png")).getImage());//Memberi favicon di jframe   
        frame.setSize(1050, 600);
        frame.setVisible(true);           
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:/Program Files/VideoLAN/VLC");//Load dll vlc
        Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);    
        
        mediaPlayerComponent = new EmbeddedMediaPlayerComponent();   
        frame.setContentPane(mediaPlayerComponent);         
               
        File dir = new File(System.getProperty("user.home"), "Videos");    // HOW SAVE TO HOST ?????
        dir.mkdirs();
        DateFormat df = new SimpleDateFormat("yyyyMMdd-HHmmss");
        String fileName = dir.getAbsolutePath() + "/Capture-" + df.format(new Date()) + ".mpeg";          
        String [] options =  {":sout=#transcode{vcodec=mpgv,vb=4094,scale=1,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=" + fileName + "},dst=display}"};
        mediaPlayerComponent.getMediaPlayer().playMedia("rtsp://10.10.10.3:554/nphMpeg4/g726-640x480",options);   
        initComponents();
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
 
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
 
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
 
        pack();
    }// </editor-fold>                        
 
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CctvUser.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CctvUser.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CctvUser.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CctvUser.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
 
        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {
 
            public void run() {
                new CctvUser();                
            }
        });
    }
    // Variables declaration - do not modify                     
    // End of variables declaration                   
}

My code:

File dir = new File(System.getProperty("user.home"), "Videos");      
//how to change pathname to url........................... ?
        
        dir.mkdirs();
        DateFormat df = new SimpleDateFormat("yyyyMMdd-HHmmss");
        String fileName = dir.getAbsolutePath() + "/Capture-" + df.format(new Date()) + ".mpeg";          
        String [] options =  {":sout=#transcode{vcodec=mpgv,vb=4094,scale=1,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=" + fileName + "},dst=display}"};
        mediaPlayerComponent.getMediaPlayer().playMedia("D:\\2.MP4",options);   

 

how to saving file to other host ?

You can't save the file to a diffent host...  
Saving a file is saving a file locally - if "the different host" has a drive mapped you can save it that way..

If your talking about streaming it to another host - the other host has to have some application which will accept the stream, and that same application must know how to save it.