无法使用FFmpegMediaMetadataRetriever从YouTube视频中获取帧

时间:2019-06-27 13:24:57

标签: android ffmpeg

我一直在尝试使用android studio项目中的FFmpegMediaMetadataRetriever从youtube视频中提取帧。每当我在setDataSource中使用youtube url时,应用程序就会崩溃。我是android studio中的新手,之前没有使用FFmpeg。如果有人可以帮助我,我将不胜感激。另外,如果我问了一个非常愚蠢/简单的问题,我也感到抱歉。

import wseemann.media.FFmpegMediaMetadataRetriever;
.....

private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {
        switch (status) {
            case LoaderCallbackInterface.SUCCESS: {
                Log.i(TAG, "OpenCV loaded successfully");
                mOpenCvCameraView.enableView();
                try {
                    initializeOpenCVDependencies();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            break;
            default: {
                super.onManagerConnected(status);
            }
            break;
        }
    }
};


private void initializeOpenCVDependencies() throws IOException {

    tick =0;
   //extract frame at 2 second using FFmpegMediaMetadataRetriever
    FFmpegMediaMetadataRetriever mmr = new FFmpegMediaMetadataRetriever();
    mmr.setDataSource("https://youtu.be/f-ehTcWC6dc");
    Bitmap b = mmr.getFrameAtTime(2000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST);
    mmr.release();

    objMat = new MatOfPoint2f();
    sceneMat = new MatOfPoint2f();
    obj_corners = new Mat(4, 1, CvType.CV_32FC2);
    img = new Mat();
    img2 = new Mat();
}

在build.gradle中,我添加了以下依赖项

dependencies {

       //FFmpegMediaMetadataRetriever dependencies
       implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'

       implementation project(path: ':openCVLibrary340dev')
}

我得到的错误是:

  

E / Android运行时:致命异常:主要       流程:com.example.jeverfun,PID:8877       java.lang.RuntimeException:无法恢复活动{com.example.jeverfun / com.example.jeverfun.jevercamera}:java.lang.IllegalArgumentException:setDataSource失败:status = 0xFFFFFFFF           在android.app.ActivityThread.performResumeActivity(ActivityThread.java:3581)           在android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2862)           在android.app.ActivityThread.-wrap11(未知来源:0)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1589)           在android.os.Handler.dispatchMessage(Handler.java:106)           在android.os.Looper.loop(Looper.java:164)           在android.app.ActivityThread.main(ActivityThread.java:6494)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:438)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)        引起原因:java.lang.IllegalArgumentException:setDataSource失败:status = 0xFFFFFFFF           在wseemann.media.FFmpegMediaMetadataRetriever.setDataSource(本机方法)           在com.example.jeverfun.jevercamera.initializeOpenCVDependencies(jevercamera.java:373)           在com.example.jeverfun.jevercamera.access $ 100(jevercamera.java:59)           在com.example.jeverfun.jevercamera $ 1.onManagerConnected(jevercamera.java:347)           在com.example.jeverfun.jevercamera.onResume(jevercamera.java:469)           在android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1355)           在android.app.Activity.performResume(Activity.java:7117)           在android.app.ActivityThread.performResumeActivity(ActivityThread.java:3556)           在android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3621)           在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2862)           在android.app.ActivityThread.-wrap11(未知来源:0)           在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1589)           在android.os.Handler.dispatchMessage(Handler.java:106)           在android.os.Looper.loop(Looper.java:164)           在android.app.ActivityThread.main(ActivityThread.java:6494)           在java.lang.reflect.Method.invoke(本机方法)           在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:438)           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)   I / MediaMetadataRetrieverJNI:发布   应用已终止。

0 个答案:

没有答案