当我运行项目时,我正在使用javacv
从图像和音频中获取视频出现此异常,请帮助我
以下是我的代码
包 com.example.ard;
import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import com.googlecode.javacv.cpp.opencv_imgproc;
import java.io.File;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.widget.Toast;
import com.googlecode.javacv.FFmpegFrameGrabber;
import com.googlecode.javacv.FFmpegFrameRecorder;
import com.googlecode.javacv.cpp.opencv_core;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
public class Cv extends Activity{
IplImage[] iplimage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getVedio();
addMusic();
}
public void getVedio(){
String path =Environment.getExternalStorageDirectory().toString()+"/VoicePic/IMG/";
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
if(listOfFiles.length>0)
{
iplimage = new opencv_core.IplImage[listOfFiles.length];
for (int j = 0; j < listOfFiles.length; j++) {
String files="";
if (listOfFiles[j].isFile())
{
files = listOfFiles[j].getName();
System.out.println(" j " +j + listOfFiles[j]);
}
String[] tokens = files.split("\\.(?=[^\\.]+$)");
String name=tokens[0];
Toast.makeText(getBaseContext(), "size"+listOfFiles.length, Toast.LENGTH_SHORT).show();
/* BufferedImage img = ImageIO.read(new File("C:\\img.jpg") );
iplimage[j] = IplImage.createFrom(img);
*/ iplimage[j]=cvLoadImage("/mnt/sdcard/Video_images/"+name+".jpg");
}
}
}
public void addMusic(){
try {
FFmpegFrameGrabber grabber1 = new FFmpegFrameGrabber("EXT/demo.mp3");
grabber1.start();
FFmpegFrameRecorder recorder = new
FFmpegFrameRecorder(Environment.getExternalStorageDirectory().toString()+"/VoicePic/REC/"+System.currentTimeMillis()+".mp4",200,150, grabber1.getAudioChannels());
recorder.setVideoCodec(1); //CODEC_ID_MPEG4 //CODEC_ID_MPEG1VIDEO
recorder.setFrameRate(24);
recorder.setPixelFormat(0); //PIX_FMT_YUV420P
recorder.start();
com.googlecode.javacv.Frame frame1 = new com.googlecode.javacv.Frame();
for (int i=0;i<iplimage.length;i++)
{
frame1 = grabber1.grabFrame();
recorder.record(frame1);
recorder.record(iplimage[i]);
}
recorder.stop();
grabber1.stop();
}catch(Exception e){
e.printStackTrace();
}
}
}
07-17 13:20:28.291: W/dalvikvm(1413): JNI WARNING: JNI method called with exception pending
07-17 13:20:28.291: W/dalvikvm(1413): in Ljava/lang/Runtime;.nativeLoad:(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/String; (FindClass)
07-17 13:20:28.291: W/dalvikvm(1413): Pending exception is:
07-17 13:20:28.291: I/dalvikvm(1413): java.lang.ClassNotFoundException: com.googlecode.javacv.cpp.opencv_imgproc$FilterEnginePtr
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.Class.classForName(Native Method)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.Class.forName(Class.java:217)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacpp.Loader.putMemberOffset(Loader.java:680)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.Runtime.nativeLoad(Native Method)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.Runtime.nativeLoad(Native Method)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.Runtime.loadLibrary(Runtime.java:368)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.System.loadLibrary(System.java:535)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacpp.Loader.load(Loader.java:489)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacpp.Loader.load(Loader.java:431)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.Class.classForName(Native Method)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.Class.forName(Class.java:217)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacpp.Loader.load(Loader.java:453)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
07-17 13:20:28.291: I/dalvikvm(1413): at com.example.ard.Cv.getVedio(Cv.java:50)
07-17 13:20:28.291: I/dalvikvm(1413): at com.example.ard.Cv.onCreate(Cv.java:24)
07-17 13:20:28.291: I/dalvikvm(1413): at android.app.Activity.performCreate(Activity.java:4470)
07-17 13:20:28.291: I/dalvikvm(1413): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
07-17 13:20:28.291: I/dalvikvm(1413): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
07-17 13:20:28.291: I/dalvikvm(1413): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
07-17 13:20:28.291: I/dalvikvm(1413): at android.app.ActivityThread.access$600(ActivityThread.java:128)
07-17 13:20:28.291: I/dalvikvm(1413): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
07-17 13:20:28.291: I/dalvikvm(1413): at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 13:20:28.291: I/dalvikvm(1413): at android.os.Looper.loop(Looper.java:137)
07-17 13:20:28.291: I/dalvikvm(1413): at android.app.ActivityThread.main(ActivityThread.java:4517)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.reflect.Method.invoke(Method.java:511)
07-17 13:20:28.291: I/dalvikvm(1413): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
07-17 13:20:28.291: I/dalvikvm(1413): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
07-17 13:20:28.291: I/dalvikvm(1413): at dalvik.system.NativeStart.main(Native Method)
07-17 13:20:28.291: I/dalvikvm(1413): "main" prio=5 tid=1 NATIVE
07-17 13:20:28.291: I/dalvikvm(1413): | group="main" sCount=0 dsCount=0 obj=0x40c2acd0 self=0x26edd0
07-17 13:20:28.291: I/dalvikvm(1413): | sysTid=1413 nice=0 sched=0/0 cgrp=default handle=1074488712
07-17 13:20:28.291: I/dalvikvm(1413): | schedstat=( 0 0 0 ) utm=19 stm=4 core=0
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.Runtime.nativeLoad(Native Method)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.Runtime.loadLibrary(Runtime.java:368)
07-17 13:20:28.291: I/dalvikvm(1413): at java.lang.System.loadLibrary(System.java:535)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacpp.Loader.load(Loader.java:489)
07-17 13:20:28.291: I/dalvikvm(1413): at com.googlecode.javacpp.Loader.load(Loader.java:431)
07-17 13:20:28.301: I/dalvikvm(1413): at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
07-17 13:20:28.301: I/dalvikvm(1413): at java.lang.Class.classForName(Native Method)
07-17 13:20:28.301: I/dalvikvm(1413): at java.lang.Class.forName(Class.java:217)
07-17 13:20:28.301: I/dalvikvm(1413): at com.googlecode.javacpp.Loader.load(Loader.java:453)
07-17 13:20:28.301: I/dalvikvm(1413): at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
07-17 13:20:28.301: I/dalvikvm(1413): at com.example.ard.Cv.getVedio(Cv.java:-1)
07-17 13:20:28.301: I/dalvikvm(1413): at com.example.ard.Cv.onCreate(Cv.java:24)
07-17 13:20:28.301: I/dalvikvm(1413): at android.app.Activity.performCreate(Activity.java:4470)
07-17 13:20:28.301: I/dalvikvm(1413): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
07-17 13:20:28.301: I/dalvikvm(1413): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
07-17 13:20:28.301: I/dalvikvm(1413): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
07-17 13:20:28.301: I/dalvikvm(1413): at android.app.ActivityThread.access$600(ActivityThread.java:128)
07-17 13:20:28.301: I/dalvikvm(1413): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
07-17 13:20:28.301: I/dalvikvm(1413): at android.os.Handler.dispatchMessage(Handler.java:99)
07-17 13:20:28.301: I/dalvikvm(1413): at android.os.Looper.loop(Looper.java:137)
07-17 13:20:28.301: I/dalvikvm(1413): at android.app.ActivityThread.main(ActivityThread.java:4517)
07-17 13:20:28.301: I/dalvikvm(1413): at java.lang.reflect.Method.invokeNative(Native Method)
07-17 13:20:28.301: I/dalvikvm(1413): at java.lang.reflect.Method.invoke(Method.java:511)
07-17 13:20:28.301: I/dalvikvm(1413): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
07-17 13:20:28.301: I/dalvikvm(1413): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
07-17 13:20:28.301: I/dalvikvm(1413): at dalvik.system.NativeStart.main(Native Method)