Java tutorial
//package com.java2s; import android.media.MediaMetadataRetriever; public class Main { public static long getVideoDurationInMillis(String videoFile) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(videoFile); String time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION); long timeInmillisec = Long.parseLong(time); retriever.release(); return timeInmillisec; } }