'Frame extractor
So, I've been trying to create a frame extractor but, obviously, it doesn't work. Here's what it look likes
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.Scanner;
import java.sql.Time;
import javax.imageio.ImageIO;
import org.bytedeco.javacv.FFmpegFrameGrabber;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.Java2DFrameConverter;
public class FrameExtract {
public static void main(String []args) throws Exception
{
System.out.println("Please enter the file name and path");
Scanner filepath = new Scanner(System.in);
String filename = filepath.nextLine();
File myObj = new File(filename);
System.out.println("Please enter the precise time of the frame you want to extract");
Scanner timeex = new Scanner(System.in);
Long timetoex = timeex.nextLong();
Time timestamp = new Time(timetoex);
FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(myObj.getAbsoluteFile());
frameGrabber.start();
Frame f;
try {
Java2DFrameConverter c = new Java2DFrameConverter();
f = frameGrabber.grab();
BufferedImage bi = c.convert(f);
ImageIO.write(bi,"png", new File("D:\\img.png"));
frameGrabber.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
and the exceptions show this:
java.util.Scanner.throwFor(Scanner.java:864)
java.util.Scanner.next(Scanner.java:1485)
java.util.Scanner.nextLong(Scanner.java:2222)
java.util.Scanner.nextLong(Scanner.java:2182)
Eng.F.FrameExtract.main(FrameExtract.java:22)
I know there is problems like the code doesn't use the time properly, or even at all
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
