0

我使用 JavaCV 创建了一个 Java 类,用于播放视频和捕获帧。视频使用 ffmpeg 在 CanvasFrame 中“播放”。我想在 JFrame 中添加该画布。那可能吗?

public static void main(String[] args) {

         //Create canvas frame for displaying video.
         CanvasFrame canvas = new CanvasFrame("VideoCanvas"); 


         File movie_name = new File("niki.mp4");

         //Declare FrameGrabber to import video from "video.mp4"
         FFmpegFrameGrabber grabber=new FFmpegFrameGrabber(movie_name); 


          //Start grabber to capture video
          grabber.start();      

          //Declare img as IplImage
          IplImage img;

          while (true) {

           //inser grabed video frame to IplImage img
           img = grabber.grab();

           //Set canvas size as per dimentions of video frame.
           canvas.setCanvasSize(grabber.getImageWidth(), grabber.getImageHeight()); 


           //Show video frame in canvas
           canvas.showImage(img); 

           //save video frame as a picture
           cvSaveImage("capture.png", img);


           }

        }
4

0 回答 0