How can I get a frame sample (jpeg) from a video (mov)

前端 未结 6 1736
谎友^
谎友^ 2020-11-30 20:13

I want to get a frame sample (jpeg) from a video file (mov) with java. Is there an easy way to do this. When I search in google all I can find is to make mov from multiple j

6条回答
  •  攒了一身酷
    2020-11-30 21:05

    Below it is shown the essential code to request frames from media files.

    For the complete source code and video demo:
    "Media File Processing" example using Marvin Framework..

    public class MediaFileExample implements Runnable{
    
        private MarvinVideoInterface    videoAdapter;
        private MarvinImage             videoFrame;
    
        public MediaFileExample(){
            try{
                // Create the VideoAdapter used to load the video file
                videoAdapter = new MarvinJavaCVAdapter();
                videoAdapter.loadResource("./res/snooker.wmv");
    
                // Start the thread for requesting the video frames 
                new Thread(this).start();
            }
            catch(MarvinVideoInterfaceException e){e.printStackTrace();}
        }
    
        @Override
        public void run() {
            try{
                while(true){
                    // Request a video frame
                    videoFrame = videoAdapter.getFrame();
                }
            }catch(MarvinVideoInterfaceException e){e.printStackTrace();}
        }
    
        public static void main(String[] args) {
            MediaFileExample m = new MediaFileExample();
        }
    }
    

提交回复
热议问题