FFMPeg exception setDataSource failed: status = 0xFFFFFFFF

3

I have 175 mp4 files. When I process file from index 0 to index 65 (or 66), I get exception:

java.lang.IllegalArgumentException: setDataSource failed: status = 0xFFFFFFFF
at wseemann.media.FFmpegMediaMetadataRetriever.setDataSource(Native Method)
at com.jni.utils.Mp4ParserUsingFFMpeg.createThumbnail(Mp4ParserUsingFFMpeg.java:518)
at com.example.readmdtfile.activity.MainActivity$createMp4Async.createThumbnail(MainActivity.java:71)
at com.example.readmdtfile.activity.MainActivity$createMp4Async.doInBackground(MainActivity.java:55)
at com.example.readmdtfile.activity.MainActivity$createMp4Async.doInBackground(MainActivity.java:1)
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)

If I run process from index 65 (or nearby), processing file 65 is successful. But it still get exception sometimes Here is code which i'm using:

public static Bitmap createThumbnail (String videoPath) {
    FFmpegMediaMetadataRetriever retriever = new  FFmpegMediaMetadataRetriever();
    Bitmap bitmap = null;
    try {
        retriever.setDataSource(videoPath); //file's path
        String key;
        String value;
        for (int i = 0; i < MetadataKey.METADATA_KEYS.length; i++) {
            key = MetadataKey.METADATA_KEYS[i];
            value = retriever.extractMetadata(key);
            if (value != null) {
                // metadata.add(new Metadata(key, value));
                Log.i(TAG, "Key: " + key + " Value: " + value);
            }
        }

        bitmap = retriever.getFrameAtTime();

        if (bitmap != null) {
            Log.d(TAG, "Extracted frame");
            Bitmap b2 = retriever.getFrameAtTime(4000000,
                    FFmpegMediaMetadataRetriever.OPTION_CLOSEST_SYNC);
            if (b2 != null) {
                bitmap = b2;
            }
        } else {
            Log.d(TAG, "Failed to extract frame");
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        retriever.release();
    }

    return bitmap;
}

https://github.com/wseemann/FFmpegMediaMetadataRetriever/issues/59

Please help me.

exception
ffmpeg
asked on Stack Overflow Jul 13, 2015 by guensuanhoa

3 Answers

1

The error is simple, an IllegalArgumentException means the video URI is invalid, if this occurs an exception is thrown. Verify the URI is valid before attempting to use it with FFmpegMediaMetadataRetriever.

answered on Stack Overflow Oct 19, 2015 by William Seemann
0

you just have to give setDataSource a String, save your path or url in a string like this:

String url;
mmr = new FFmpegMediaMetadataRetriever();
url = "http://www.stephaniequinn.com/Music/Commercial%20DEMO%20-%2009.mp3";
mmr.setDataSource(url, new HashMap<String, String>());

or:

mmr = new FFmpegMediaMetadataRetriever();
string s="path"
mmr.setDataSource(path);
answered on Stack Overflow Nov 3, 2015 by Lily Sedghi • edited Aug 8, 2016 by Lily Sedghi
0

The error is simple, an RuntimeException means the video URI is invalid. Verify the valid Video URI with .mp4 format, before attempting to use it with FFmpegMediaMetadataRetriever.

ImageView thumbnail1 = (ImageView) findViewById(R.id.video1);
thumbnail1.setImageBitmap(retriveVideoFrameFromVideo("http://techslides.com/demos/sample-videos/small.mp4"));

public Bitmap retriveVideoFrameFromVideo(String videoPath) {
    Bitmap bitmap = null;
    MediaMetadataRetriever mediaMetadataRetriever = null;
    try {
        mediaMetadataRetriever = new MediaMetadataRetriever();
        if (Build.VERSION.SDK_INT >= 14)
            mediaMetadataRetriever.setDataSource(videoPath, new HashMap<String, String>());
        else
            mediaMetadataRetriever.setDataSource(videoPath);
        //   mediaMetadataRetriever.setDataSource(videoPath);
        bitmap = mediaMetadataRetriever.getFrameAtTime(1, MediaMetadataRetriever.OPTION_CLOSEST);
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    } finally {
        if (mediaMetadataRetriever != null) {
            mediaMetadataRetriever.release();
        }
    }
    return bitmap;
}
answered on Stack Overflow Sep 18, 2018 by Chathura Manoj Hasaranga • edited Sep 11, 2019 by Nikolai Shevchenko

User contributions licensed under CC BY-SA 3.0