'When Grabbing a File through JFileChooser why does this fail?
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());
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|