2017-03-10 17 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; 
} 
関連する問題