通过Jfilechooser抓住文件时,为什么会失败?
我试图了解Java Swing Guis。因此,我创建了一个简单的GUI来选择一个文件。
当我尝试使用FFMPEG包装器获取文件信息时,我会收到以下错误。
java.io.ioexception:无法运行程序“ c:\ file.mp4”:createProcess错误= 193,%1不是有效的win32应用程序。
我觉得我在这里缺少一些小东西。 谢谢。
JFileChooser fc = new JFileChooser();
int nReturnVal = fc.showOpenDialog(jPanel1);
File fVideo = null;
try {
if (nReturnVal == JFileChooser.APPROVE_OPTION) {
fVideo = fc.getSelectedFile();
//Now you have your file to do whatever you want to do
jPath.setText(fVideo.getAbsolutePath());
FFprobe ffprobe = new FFprobe(fVideo.getAbsoluteFile().toString());
FFmpegProbeResult probeResult = ffprobe.probe(fVideo.getAbsolutePath());
FFmpegFormat format = probeResult.getFormat();
System.out.format("%nFile: '%s' ; Format: '%s' ; Duration: %.3fs",
format.filename,
format.format_long_name,
format.duration);
jEndTime.setText("" + format.duration);
} else {
//User did not choose a valid file
}
}
catch (Exception ex) {
System.out.println(ex.toString());
}
I'm trying to understand Java Swing GUIs. So I created a simple GUI to select a File.
When I attempt to use the FFMPEG wrapper to get file information I get the following error.
java.io.IOException: Cannot run program "C:\File.mp4": CreateProcess error=193, %1 is not a valid Win32 application.
I feel like I'm missing something minor here.
Thanks.
JFileChooser fc = new JFileChooser();
int nReturnVal = fc.showOpenDialog(jPanel1);
File fVideo = null;
try {
if (nReturnVal == JFileChooser.APPROVE_OPTION) {
fVideo = fc.getSelectedFile();
//Now you have your file to do whatever you want to do
jPath.setText(fVideo.getAbsolutePath());
FFprobe ffprobe = new FFprobe(fVideo.getAbsoluteFile().toString());
FFmpegProbeResult probeResult = ffprobe.probe(fVideo.getAbsolutePath());
FFmpegFormat format = probeResult.getFormat();
System.out.format("%nFile: '%s' ; Format: '%s' ; Duration: %.3fs",
format.filename,
format.format_long_name,
format.duration);
jEndTime.setText("" + format.duration);
} else {
//User did not choose a valid file
}
}
catch (Exception ex) {
System.out.println(ex.toString());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论