2017-03-10 2 views
0

친애하는 모든,
나는 MP4 비디오에서 GPS 위치에 액세스해야하는 새 프로젝트를 진행 중입니다. 여기에 시도했지만, Null Pointer Exception을 얻는 코드가 있습니다.GPS 위치를 얻는 mp4parser

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(); 

감사합니다,

답변

0

이 코드는 나를 위해 일했다. 위치 태그를 사용할 수 없을 때 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; 
} 
관련 문제