1

There are Number of ways to check video file Meta data , using FFmpegMediaMetadataRetriever(Slow but reliable) and using Native MediaMetadataRetriever(Slow and not reliable).

There are number of question answered in SO for same purpose to get MetaData using FFMPEG or Native Media api , like Q1 , Q2 , Q3 but they are not solving my problem.

My Problem:

Get following meta data from file(Video) of android directory:

  • Video have Sound/Audio or not?
  • Creation date and time
  • thumbnail of video file

Kindly let me know if you have any suggestion or code samples would be big help.

Zulqurnain Jutt
  • 1,077
  • 1
  • 9
  • 21

1 Answers1

0

when i want check video has audio or not that time i created this method. method return True if Video has Audio otherwise False

just you pass Context and Uri of Your video file

private boolean setHasAudioOrNot(JoinVideoActivity activity, Uri uri) {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    retriever.setDataSource(activity.getApplicationContext(),uri);
    Log.e("Command","audiohas?? " +retriever.extractMetadata(16));
    return retriever.extractMetadata(16) != null;
}
Sanjay Hadiya
  • 864
  • 9
  • 21
  • What if the file has no metadata? Then it will return `IllegalArgumentException ` – ClassA Oct 15 '18 at 06:36
  • 1
    if input file is file than it must have metadata if not than we can't use this method @ClassA – Sanjay Hadiya Oct 15 '18 at 06:40
  • `if input file is file than it must have metadata` not all encoders add metadata, If you use this in your application you will most definitely get `IllegalArgumentException`. The question - `Fastest way to check if Video File have Following MetaData?` - In your answer you don't check if the file has the metadata, you assume the metadata is available. – ClassA Oct 15 '18 at 06:49
  • hey buddy this snippet put in try and catch block if occur exception than handle so we save from crash – Sanjay Hadiya Oct 15 '18 at 06:52
  • Yes, I know that, buddy. Even if you put this method in a `try/catch`, you still don't answer the question OP asked, `check if Video File have Following MetaData`. You currently check if a file has audio using metadata, you don't check if the metadata is available. – ClassA Oct 15 '18 at 07:01
  • hey bro please read this line carefully --> when i want check video has audio or not that time i created this method. method return True if Video has Audio otherwise False <<<< my answer only for check video has audio or not okk – Sanjay Hadiya Oct 15 '18 at 07:07