I am trying to get duration of remote videos (which range from 5 seconds to 10 minutes), I am currently testing with 4 videos on my remote server, I am able to get the duration of 1 or 2 videos while the others throw a IllegalArgumentException setDataSource failed: status = 0xFFFFFFFF
. This doesn't always happen with the same videos, if I run the code again, some videos will successfully return the duration (even if they failed when running the code previously) while others that returned the duration will fail, basically it's random, some fail and some are successful and this results changes with each launch eg:
run code #1
run code #2
run code #3
etc..
code:
private void getFTP_DurationArray() {
//Get File Names From FTP
FTPClient client = new FTPClient();
try {
client.connect(myFTP_Server);
client.enterLocalPassiveMode();
client.login(myFTP_Username, myFTP_Password);
client.changeWorkingDirectory(skyVideos_OPEN_Active_ftpDir);
FTPFile[] files = client.listFiles();
//SORT BY TIMESTAMP
Arrays.sort(files,
Comparator.comparing((FTPFile remoteFile) -> remoteFile.getTimestamp()).reversed());
file_path_remote = myDomain + "/" + skyVideos_OPEN_Active;
for (FTPFile file : files) {
if (file.isFile())
{
//GetDuration
try{
//NOTE: must not use https
mmr = new FFmpegMediaMetadataRetriever();
mmr.setDataSource(myDomain_no_https + "/" + skyVideos_OPEN_Active+"/"+file.getName());
long duration =Long.parseLong(mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_DURATION));
duration=duration/1000;
long minute=duration/(60);
long second=duration-(minute*60);
mmr.release();
strDuration = String.format("%02d:%02d" , minute, second);
Log.d("LOG", "strDuration " +strDuration + " -> "+file_name_remote);
arrListStr_Duration.add(strDuration);
stringArr_Duration = new String[arrListStr_Duration.size()];
stringArr_Duration = arrListStr_Duration.toArray(stringArr_Duration);
} catch (IllegalStateException e) {
Log.d("LOG", "IllegalStateException " + " -> "+e + " "+file_name_remote);
}catch (IllegalArgumentException e) {
Log.d("LOG", "IllegalArgumentException " + " -> "+e +" "+file_name_remote);
}
}
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
Log.d("LOG", "IOException: " +e);
}
}
User contributions licensed under CC BY-SA 3.0