mp4parser 获取 GPS 位置
mp4parser getting GPS location
亲爱的大家,
我正在处理一个新项目,我需要从 MP4 视频访问 GPS 位置。这是我试过的代码,但出现空指针异常。
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();
谢谢,
嗯
这段代码对我有用。当没有位置标签可用时,它会给出 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;
}
亲爱的大家,
我正在处理一个新项目,我需要从 MP4 视频访问 GPS 位置。这是我试过的代码,但出现空指针异常。
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();
谢谢,
嗯
这段代码对我有用。当没有位置标签可用时,它会给出 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;
}