mp4parser получает местоположение GPS
Дорогие все,
Я работаю над новым проектом, в котором мне нужно получить доступ к местоположению GPS из видео MP4. Вот код, который я пробовал, но получаю исключение Null Pointer.
File videoFile = new File(videoFilePath);
if (!videoFile.exists()) {
throw new FileNotFoundException("File " + videoFilePath + " not exists");
}
if (!videoFile.canRead()) {
throw new IllegalStateException("No read permissions to file " + videoFilePath);
}
IsoFile isoFile = new IsoFile(videoFilePath);
AppleNameBox nam = Path.getPath(isoFile, "/moov[0]/udta[0]/meta[0]/ilst/©xyz");
String xml = nam.getValue();
Спасибо,
Ом
1 ответ
Решение
Этот код работал для меня. Это дает NPE, когда нет доступных меток местоположения.
private String readVideoLocation(String fullFilePath) throws Exception {
File videoFile = new File(fullFilePath);
if (!videoFile.exists()) {
throw new FileNotFoundException("File " + fullFilePath + " not exists");
}
if (!videoFile.canRead()) {
throw new IllegalStateException("No read permissions to file " + fullFilePath);
}
FileDataSourceImpl fileDataSource = new FileDataSourceImpl(fullFilePath);
IsoFile isoFile = new IsoFile(fileDataSource);
AppleGPSCoordinatesBox locBox = Path.getPath(isoFile, "/moov[0]/udta[0]/meta[0]/ilst/©xyz");
String xml = locBox.getValue();
isoFile.close();
return xml;
}