wseemann / FFmpegMediaMetadataRetriever

FFmpegMediaMetadataRetriever provides a unified interface for retrieving frame and meta data from an input media file.
1.73k stars 387 forks source link

setDataSource crash due to UTF-8 chars #212

Open Hackmodford opened 5 years ago

Hackmodford commented 5 years ago

FFmpegMediaMetadataRetriever crashes when certain chars are used in the path.

I iterated through all the UTF-8 characters to find which ones would cause the crash.

08-29 18:34:17.432 E: FOUND INVALID CHAR 35 #
08-29 18:34:17.662 E: FOUND INVALID CHAR 37 %
08-29 18:34:22.512 E: FOUND INVALID CHAR 58 :
08-29 18:34:23.462 E: FOUND INVALID CHAR 63 ?

This is how I am using a File to set the datasource.

File renamed = //file that was renamed with char added.
final Uri fileUri = Uri.parse(renamed.getAbsolutePath());
metadataRetriever.setDataSource(context, fileUri);

Should FFmpegMediaMetadataRetriever be able to handle this, or do I need to check for these characters in file names?

LiuPangYao commented 5 years ago

someone know how to fix this issue. .mp4 file is successful. mov is fail

Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (greylist, JNI, allowed) use public void setDataSource(Context context, Uri uri) anyone know how to fix

HBiSoft commented 4 years ago

I can confirm this..

When selecting a file with the following name test#12%34.mp4, for example, you will get the following crash:

Caused by java.lang.IllegalArgumentException: setDataSource failed: status = 0xFFFFFFFF
       at wseemann.media.FFmpegMediaMetadataRetriever.setDataSource(FFmpegMediaMetadataRetriever.java)
       at wseemann.media.FFmpegMediaMetadataRetriever.setDataSource + 222(FFmpegMediaMetadataRetriever.java:222)
       at com.your.package.name$ThumbnailRetrievalTask.doInBackground + 2990(name.java:2990)
       at com.your.package.name$ThumbnailRetrievalTask.doInBackground + 2975(name.java:2975)
       at android.os.AsyncTask$2.call + 333(AsyncTask.java:333)
       at java.util.concurrent.FutureTask.run + 266(FutureTask.java:266)
       at android.os.AsyncTask$SerialExecutor$1.run + 245(AsyncTask.java:245)
       at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run + 764(Thread.java:764)
flykule commented 4 years ago

Try this, I also face this problem:

if (path.startsWith("http")) {
            try {
                int index = path.lastIndexOf("/");
                if (index > 0) {
                    String sub = path.substring(index + 1);
                    path = path.substring(0, index + 1) + URLEncoder.encode(sub, "utf-8");
                }
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
suiyuanchen commented 3 years ago

I can confirm this..

When selecting a file with the following name test#12%34.mp4, for example, you will get the following crash:

Caused by java.lang.IllegalArgumentException: setDataSource failed: status = 0xFFFFFFFF
       at wseemann.media.FFmpegMediaMetadataRetriever.setDataSource(FFmpegMediaMetadataRetriever.java)
       at wseemann.media.FFmpegMediaMetadataRetriever.setDataSource + 222(FFmpegMediaMetadataRetriever.java:222)
       at com.your.package.name$ThumbnailRetrievalTask.doInBackground + 2990(name.java:2990)
       at com.your.package.name$ThumbnailRetrievalTask.doInBackground + 2975(name.java:2975)
       at android.os.AsyncTask$2.call + 333(AsyncTask.java:333)
       at java.util.concurrent.FutureTask.run + 266(FutureTask.java:266)
       at android.os.AsyncTask$SerialExecutor$1.run + 245(AsyncTask.java:245)
       at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run + 764(Thread.java:764)

I also face this problem