我正在尝试创建一个java程序,它将记录来自我的网络摄像头(或其他一些流/源)的视频和音频。我正在使用vlcj教程中的代码,当我在Netbeans中运行它时,我没有得到任何错误消息,但它只记录音频,如果acodec是mpga,只有视频,如果acodec是mpga。这是我的代码:
package cyclops;
/**
*
* @author Black Tie
*/
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
public class Cyclops {
private final EmbeddedMediaPlayerComponent mediaPlayerComponent;
public static void main(final String[] args) {
NativeLibrary.addSearchPath(
RuntimeUtil.getLibVlcLibraryName(),"C:\\Program Files\\VideoLAN\\VLC");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(),LibVlc.class);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new Cyclops();
}
});
}
private Cyclops() {
mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
JFrame frame = new JFrame("Lesson Record");
frame.setContentPane(mediaPlayerComponent);
frame.setLocation(100, 100);
frame.setSize(450, 450);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
String mediaURL= "dshow://";
mediaPlayerComponent.getMediaPlayer().playMedia(mediaURL,":sout=#transcode{vcodec=h264,venc=x264{cfr=16},scale=1,acodec=mpga,ab=160,channels=2,samplerate=44100}:file{dst=C:\\Users\\Black Tie\\Documents\\vlcVideos\\trial13j.mpg");
}
}
如果有人能就可能出现的问题向我提出建议,我将非常感激。 感谢。