jsp site uses ffmpeg implemented as .flv format video capture

ffmpeg.jsp file
<body>      
  <%
        String ffmpegPath = "C: \\ the Apache-Tomcat webapps-6.0.30 \\ \\ \\ project001 ffmpeg"; // ffmpeg.exe and pthreadGC2.dll file folder where the path
        String sourcePath = "C: \ \ apache-tomcat-6.0.30 \\ webapps \\ project001 \\ flash \\ good.flv "; // video path where the
        String destPath =" C: \\ apache -tomcat-6.0.30 \\ webapps \\ project \\ flash "; // save the interception out of the picture file to the path
        String fileName =" good "; // interception out of the picture file name
        int a = com.adouteam.www.util.ffmpeg.videoIntercept (ffmpegPath, sourcePath , destPath, fileName); // call the java file, execute intercept
     %>
</body>
com.adouteam.www.util.ffmpeg.java
FFmpeg {class public
    public static int videoIntercept (ffmpegPath String, String the sourcePath, destPath String, String fileName) throws IOException {
        // target path exists target path is established
        File dest = new new File (destPath);
        IF (dest.exists (! )) {
            dest.mkdirs ();
        }
        // source file (video) path does not exist is returned
        file source = new new file (the sourcePath);
        ! IF (source.exists ()) {
            return 0;
        }

        Runtime rt = Runtime.getRuntime (); // New RunTime
        // call the ffmpeg command screenshot        
        {the try
            // generated command line, and invoke command generator 600 * 500jpg ffmpeg file
            cmd = ffmpegPath + "\\ ffmpeg.exe -i " + sourcePath + "-y -f image2 -ss 8 -t 0.001 -s 600 * 500 "+ destPath +" \\ "+ fileName +" .jpg ";
            rt.exec (cmd);
            return. 1;
        } the catch (IOException E) {
            e.printStackTrace ();
            return 0;
        }
 }
Note: 1, generated picture destPath path and the path to be the same as the video sourcePath
              2, the key to the command line parameters, "- ss 8" represents eight seconds when the interception of the picture, "600 * 500" represents the size of the picture
              3, ffmpeg there are many other features, here only by the interception of the picture from the video as an example, other commands refer to the following link
              4, welcome to master Correction
Extended Ffmpeg Quick Command Reference link:

This article comes from " learning is endless " blog, be sure to keep this source http://ijustdoit.blog.51cto.com/5682691/968414

Reproduced in: https: //my.oschina.net/ijustdoit/blog/207427

Guess you like

Origin blog.csdn.net/weixin_33720078/article/details/92055068