I am trying to get the metadata for the video files stored on my app's user's phone. I can get the file name, id, date taken and so on. However, latitude and longitude data always returns as 0.0. I have been referring to this:
developer.android.com/reference/android/provider/MediaStore.Video.VideoColumns.html
Yes, I am already enabling use location in my settings. I have a very similar function to this for images which works fine.
public void getLocalVideoFiles(Context context) {
ContentResolver videoResolver = context.getContentResolver();
Uri videoUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
String test = getRealPathFromURI(context, videoUri);
Cursor videoCursor = videoResolver.query(videoUri, null, null, null, null);
if(videoCursor!=null && videoCursor.moveToFirst()){
//get columns
int latColumn = videoCursor.getColumnIndex
(MediaStore.Video.Media.LATITUDE);
int lonColumn = videoCursor.getColumnIndex
(MediaStore.Video.Media.LONGITUDE);
do {
String thisLat = Double.toString(videoCursor.getDouble(latColumn));
String thisLon = Double.toString(videoCursor.getDouble(lonColumn));
Log.d("video Latitude",thisLat);
Log.d("video Longitude",thisLon);
}
while (videoCursor.moveToNext());
}
return localClips;
}
The approach described here: Geotagging a captured video yields similar results (null value in the METADATA_KEY_LOCATION column).
So, my question is: does the built-in Android video tool record location data when creating videos? It seems like the answer is no, but I don't understand why there are columns for the location data if this is the case. If that is not the case, how can I access the video location data? I need the location of video files that have already been taken.
Thanks in advance!
Well i've just tested your assumption that google does not keep location data while recording video and it's incorrect.
For example: using my nexus 5 with version 5.1 i was able to get a geotag on a video i just took. you can try it by yourself and if your phone is rooted, just browse the MediaStore
external DB (com.android.providers.media) using some SQLITE viewer
but let's say that google does not keep GeoTag. there are number of reasons why they would keep such a column:
To allow users who are implementing Video recorder a way to save current location ( using FusedLocation or something similar). a way of doing it is just updating the relevant row in the DB for example:
getContentResolver().update(MediaStore.Video.Media.EXTERNAL_CONTENT_URI.buildUpon().appendPath("2152").build(), cv, null, null);
to support previous versions that did support tagging
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With