Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Java中从视频创建图像帧时出错_Java - Fatal编程技术网

在Java中从视频创建图像帧时出错

在Java中从视频创建图像帧时出错,java,Java,我想用Xugle从视频中捕获图像。在lib文件夹中添加xuggle-xuggler-3.0.660.jar。它给出了以下错误: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at com.xuggle.ferry.JNILibraryLoader.<clinit>(JNILibraryLoader.java:47) at com.xuggle.xuggler.XugglerJNI.<clinit&

我想用Xugle从视频中捕获图像。在lib文件夹中添加xuggle-xuggler-3.0.660.jar。它给出了以下错误:

java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at com.xuggle.ferry.JNILibraryLoader.<clinit>(JNILibraryLoader.java:47)
    at com.xuggle.xuggler.XugglerJNI.<clinit>(XugglerJNI.java:19)
    at com.xuggle.xuggler.Global.<clinit>(Global.java:240)
    at testing.VideoThumbnailsExample.<clinit>(VideoThumbnailsExample.java:55)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 4 more
Exception in thread "main" Java Result: 1  

请告诉我我应该做什么?

根据这个
java.lang.NoClassDefFoundError:org/slf4j/LoggerFactory
你必须将sl4j jar文件包含到你的项目构建路径中,你可以从

jenuine下载它。我已经在构建路径中添加了slf4j-simple-1.6.1.jar和slf4j.api-1.6.1.jar。但是现在它给出了以下错误[main]错误com.xuggle.ferry.JNILibraryLoader-无法加载库:xuggle xuggler;版本:3;访问以查找此问题的常见解决方案java.lang.UnsatisfiedLinkError:com.xuggle.xuggler.XugglerJNI.Global_NO_PTS_get()J位于com.xuggle.xuggler.xuggler.Global.java:240,位于testing.videothumbsample。(无法加载库:xuggle xuggler:我认为该库有问题,您是否添加了所有依赖库
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testing;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.xuggle.mediatool.IMediaReader;
import com.xuggle.mediatool.MediaListenerAdapter;
import com.xuggle.mediatool.ToolFactory;
import com.xuggle.mediatool.event.IVideoPictureEvent;
import com.xuggle.xuggler.Global;

public class VideoThumbnailsExample {
    public static final double SECONDS_BETWEEN_FRAMES = 10;
    private static final String inputFilename = "D:/bailey.mpg";
    private static final String outputFilePrefix = "c:/photo/a/mysnapshot";
    // The video stream index, used to ensure we display frames from one and
    // only one video stream from the media container.
    private static int mVideoStreamIndex = -1;
    // Time of last frame write
    private static long mLastPtsWrite = Global.NO_PTS;
    public static final long MICRO_SECONDS_BETWEEN_FRAMES = (long)(Global.DEFAULT_PTS_PER_SECOND * SECONDS_BETWEEN_FRAMES);

    public static void main(String[] args) {
        IMediaReader mediaReader = ToolFactory.makeReader(inputFilename);
        // stipulate that we want BufferedImages created in BGR 24bit color space
        mediaReader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
        mediaReader.addListener(new ImageSnapListener());
        // read out the contents of the media file and
        // dispatch events to the attached listener
        while (mediaReader.readPacket() == null) ;
    }

    private static class ImageSnapListener extends MediaListenerAdapter {
        public void onVideoPicture(IVideoPictureEvent event) {
            if (event.getStreamIndex() != mVideoStreamIndex) {
                // if the selected video stream id is not yet set, go ahead an
                // select this lucky video stream
                if (mVideoStreamIndex == -1)
                    mVideoStreamIndex = event.getStreamIndex();
               else // no need to show frames from this video stream
                 return;
           }

           // if uninitialized, back date mLastPtsWrite to get the very first frame
           if (mLastPtsWrite == Global.NO_PTS)
                mLastPtsWrite = event.getTimeStamp() - MICRO_SECONDS_BETWEEN_FRAMES;
            // if it's time to write the next frame
            if (event.getTimeStamp() - mLastPtsWrite >= MICRO_SECONDS_BETWEEN_FRAMES) {
                String outputFilename = dumpImageToFile(event.getImage());
                // indicate file written
                double seconds = ((double) event.getTimeStamp()) / Global.DEFAULT_PTS_PER_SECOND;
                System.out.printf("at elapsed time of %6.3f seconds wrote: %s\n", seconds, outputFilename);
                // update last write time
                mLastPtsWrite += MICRO_SECONDS_BETWEEN_FRAMES;
            }
        }

        private String dumpImageToFile(BufferedImage image) {
           try {
                String outputFilename = outputFilePrefix + System.currentTimeMillis() + ".png";
                ImageIO.write(image, "png", new File(outputFilename));
                return outputFilename;
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }
    }
}