我从youtube创建视频列表,我显示缩略图,持续时间视频,标题,但是当我想获得持续时间视频错误时,我尝试如下:
public static String getDuration(String url){
FFmpegMediaMetadataRetriever mmr = new FFmpegMediaMetadataRetriever();
mmr.setDataSource(url);
String time = mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_DURATION);
long timeInmillisec = Long.parseLong( time );
long duration = timeInmillisec / 1000;
long hours = duration / 3600;
long minutes = (duration - hours * 3600) / 60;
long seconds = duration - (hours * 3600 + minutes * 60);
return hours+":"+minutes;
}
是否有从youtube或任何视频网址获取持续时间视频的步骤?