首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mp4parser定位

mp4parser定位
EN

Stack Overflow用户
提问于 2017-03-10 15:55:25
回答 1查看 107关注 0票数 0

尊敬的各位:

我正在工作的新项目,我需要从MP4视频访问全球定位系统定位。下面是我尝试过的代码,但是得到了Null指针异常。

代码语言:javascript
复制
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();

谢谢,

Om

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-26 03:29:00

这个密码对我有用。当没有位置标签可用时,它会给出NPE。

代码语言:javascript
复制
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;
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42722545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档