我最近試圖記錄我的屏幕使用我在這裏找到的示例代碼之一的示例代碼的修改版本,但你可以看到自己,保存的文件的幀率是非常可怕的。你能幫忙嗎? 這裏是我使用的代碼:FrameRate問題與vlcj
public class CaptureTest {
private final MediaPlayerFactory factory;
private final HeadlessMediaPlayer mediaPlayer;
public static void main(final String[] args) {
boolean found = new NativeDiscovery().discover();
System.out.println(found);
System.out.println(LibVlc.INSTANCE.libvlc_get_version());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new CaptureTest().start("screen://");
}
});
}
public CaptureTest() {
factory = new MediaPlayerFactory();
mediaPlayer = (HeadlessMediaPlayer) factory.newHeadlessMediaPlayer();
}
private void start(String mrl) {
File dir = new File(System.getProperty("user.home"), "Videos");
dir.mkdirs();
String fileName = "C:\\Users\\Reza Taheri\\Documents\\video7.mp4";
String[] options = {
":sout=#transcode{vcodec=h264,venc=x264{cfr=16},acodec=mp4a,vfilter=canvas{width=854,height=480},samplerate=4096}:std{mux=mp4,access=file,dst=" + fileName + "}", ":input-slave=screen://",":screen-fps=24"
};
JPanel cp = new JPanel();
JButton recordButton = new JButton("Record");
cp.add(recordButton);
JFrame frame = new JFrame("vlcj");
frame.setContentPane(cp);
frame.setLocation(10, 10);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
mediaPlayer.stop();
mediaPlayer.release();
}
});
recordButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
frame.setState(JFrame.ICONIFIED);
mediaPlayer.playMedia(mrl, options);
}
});
frame.setVisible(true);
}
}
我使用Windows 10 vlcj和VLC媒體播放器的最新版本。