gpt4 book ai didi

android - JavaCV 从图像崩溃生成视频

转载 作者:行者123 更新时间:2023-11-29 00:15:31 29 4
gpt4 key购买 nike

我从昨天开始用 android 做 javacv,在使用 FFmpegFrameRecorderFrameRecorder 从图像 (IplImage) 生成视频时出错,同时在使用 cvCvtColor 的图像过滤中获得成功cvCvtColor

grayscale

如图所示,灰度翻转滤镜是通过点击第二个按钮(应用效果)完成的。

但是当点击(制作视频)时它崩溃了。

这是我从图像制作视频的代码。

String path = Environment.getExternalStorageDirectory().getPath() + "/test.mp4";
Log.i("path", path);
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(path, 256, 256);
try {

recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG4);
// recorder.setCodecID(avcodec.AV_CODEC_ID_H263);
recorder.setFormat("mp4");
recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
recorder.start();
for (int i = 0; i < 10; i++) {

recorder.record(image);
}
recorder.stop();
} catch (Exception e) {

e.printStackTrace();
}

image 是 IplImage 类型

在创建记录器 对象时出错。

我正在使用 2 个设备

1)华硕 zenfone 5

堆栈跟踪

Caused by: java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avcodec
at org.bytedeco.javacpp.Loader.load(Loader.java:387)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.avformat.<clinit>(avformat.java:13)
at org.bytedeco.javacv.FFmpegFrameRecorder.<clinit>(FFmpegFrameRecorder.java:106)
at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avcodec
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at org.bytedeco.javacpp.Loader.load(Loader.java:385)
            at org.bytedeco.javacpp.Loader.load(Loader.java:353)
            at org.bytedeco.javacpp.avformat.<clinit>(avformat.java:13)
            at org.bytedeco.javacv.FFmpegFrameRecorder.<clinit>(FFmpegFrameRecorder.java:106)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/com.example.javacvex1-1/libjniavcodec.so" has unexpected e_machine: 40
at java.lang.Runtime.loadLibrary(Runtime.java:364)
at java.lang.System.loadLibrary(System.java:526)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:410)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.avcodec.<clinit>(avcodec.java:12)
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:251)
            at org.bytedeco.javacpp.Loader.load(Loader.java:385)
            at org.bytedeco.javacpp.Loader.load(Loader.java:353)
            at org.bytedeco.javacpp.avformat.<clinit>(avformat.java:13)
            at org.bytedeco.javacv.FFmpegFrameRecorder.<clinit>(FFmpegFrameRecorder.java:106)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/com.example.javacvex1-1/libavcodec.so" has unexpected e_machine: 40

2) Htc me 平板电脑

(堆栈跟踪)

Caused by: java.lang.ExceptionInInitializerError
at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.ExceptionInInitializerError
at org.bytedeco.javacv.FFmpegFrameRecorder.<clinit>(FFmpegFrameRecorder.java:106)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
            at android.os.AsyncTask$2.call(AsyncTask.java:264)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at org.bytedeco.javacpp.Loader.load(Loader.java:385)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.avformat.<clinit>(avformat.java:13)
            at org.bytedeco.javacv.FFmpegFrameRecorder.<clinit>(FFmpegFrameRecorder.java:106)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
            at android.os.AsyncTask$2.call(AsyncTask.java:264)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1936]: 76 could not load needed library 'libavcodec.so' for 'libjniavcodec.so' (find_library[1199]: 76 'libavcodec.so' failed to load previously)
at java.lang.Runtime.loadLibrary(Runtime.java:370)
at java.lang.System.loadLibrary(System.java:535)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:410)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.avcodec.<clinit>(avcodec.java:12)
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:217)
            at org.bytedeco.javacpp.Loader.load(Loader.java:385)
            at org.bytedeco.javacpp.Loader.load(Loader.java:353)
            at org.bytedeco.javacpp.avformat.<clinit>(avformat.java:13)
            at org.bytedeco.javacv.FFmpegFrameRecorder.<clinit>(FFmpegFrameRecorder.java:106)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.makeVideo(MainActivity.java:191)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:180)
            at com.example.javacvex1.MainActivity$asyncImageProcVideo.doInBackground(MainActivity.java:152)
            at android.os.AsyncTask$2.call(AsyncTask.java:264)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1936]: 76 could not load needed library 'libswresample.so' for 'libavcodec.so' (load_library[1091]: Library 'libswresample.so' not found)

最后,我将带有 jniLibsbuild.gradle 放在左侧。

enter image description here

没有其他问题的答案。自过去 24 小时以来一直停滞不前。 :(

任何帮助都会很棒。

最佳答案

正如这篇文章中所讨论的 https://groups.google.com/forum/#!topic/javacv/Q_jxavoWdZE

我终于通过添加解决了

Loader.load(swresample.class);

在创建 FFmpegFrameRecorder 对象之前。谢谢。

关于android - JavaCV 从图像崩溃生成视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27183307/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com