Extract GPS Metadata from .MP4 and create .GPX using Exiftool

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up guys it's franchise923 and in this video i want to talk about this cool tool called exif tool so this is a tool that can help read metadata extended metadata from different types of files we're going to be using this to extract from a video file or an mp4 file so i have a dash cam that come sits in my car and as i drive it actually logs the gps data inside it's embedded inside the mp4 file so a lot of like gopros do this as well so if you're interested in learning how to extract the metadata out of that mp4 file using a free and open source tool that has a command line option then yeah just keep watching and i'm going to go over the the basics of using this exif tool so if that sounds interesting let's just jump right in and i'm going to download this i'm on a windows machine here so i'm just going to download the windows executable and it looks like it's just a zip file so i'm going to show this in the folder and extract this and we'll see what's inside this folder so you see we have this exif tool with a k and then exe so if we just double click this let's see what happens oh yeah we'll allow this to run uh you're seeing like it's kind of just spitting out the information the like the options or the documentation so basically let's just read the instructions here it says if you leave it with x tool dash k you can if you run it you'll see the documentation you can also drag and drop files and folders to view metadata so let me just show you how that works so i have some mp4 files here if i go to this location i should just be able to drag an mp4 file all right on top of this executable like that and it see how it says open with exif tool so this is just an easy way to get the metadata out of here so you see it's spinning everything back but we don't want to do this we actually want to use the command line so we can get more options because you can see here we don't see any gps data so we need to actually use the command line here so it says or rename to exit.exe for command line use so that's what we're going to do here so let's rename this let's get rid of the parentheses exit tool.exe and now i'm going to shift right click copy as path and open it up in a command line so now if i run that you see it's giving us the information so all right that works so now we need to learn more about the command line so i'm going to google exif tool documentation and on this first page here we see a bunch of options so these are all the flags that you can run with the command line and to get started we're going to keep it simple and we're going to use this dash ee which stands for extract embedded so this if we run it with dash ee it's going to extract information from embedded files so let's construct our command so what it's going to be is i'm going to shift right click we need the full path to the executable now we need dash ee for extract embedded and now we need an mp4 file so same thing shift right click copy as path all right so just like that let's see what happens when we run this so i'm going to copy it all clear the screen with cls and then run it in the command line here so now you see it's returning all this gps information so it's basically digging a little bit further in the mp4 file looking for any any other metadata it finds so you see it's spinning out the same stuff it was before but now it's also giving us more data so that's cool um what what might we want to do next so something easy so let's say you just wanted to get this into a file we can it's called piping it we can just pipe it to a file with that greater than sign and then just give it the location you want to put it in so i'm going to actually copy this paste it and then just change the name here to exif tool output test dot text and if we copy all this let's clear the screen again and run it you'll notice we don't get as much output we actually don't get any because it's all going to this text file so now here's the text file if i open that we get the same data but just in a text file so that's cool but this type of file isn't really uh like a recognized geospatial format really it's just a text file so we can't like drag this into qgis or arcgis because it doesn't know what to do with it so we need to basically format this in a different format so instead of whatever this default format is we need to give it a new format so the way to do that is with this dash p format file print output in a specified format okay so we're gonna go back here i'm just gonna copy our command here and now let's this is going to be the gpx format so gpx is like a a widely recognized um format for gps files so we're going to keep the same format let's get rid of this and this is going to be our first flag after the executable so we're just going to say dash p and now we need to tell it what format we want it to be in so we want it to be in gpx and you actually need to supply it with a gpx file like basically a sample file for it to work with because right now if you say dash p gpx it doesn't know what that format is so this is kind of a little tricky and i had to google this but basically we need to get this gpx.fmt file so just google gpx.fmt and go to the second uh hit here on github not the first this is an older version we want to use this version and make sure it says 10.49 or later and this is just it's a format file it's just telling the exif tool what gpx is and how to make it so if we copy this we're just going to make this file so paste it and then just save it as let's save it as we have to save as gpx.fmt actually you might not have to but we're going to save it like that and now where did i save that right here i'm going to shift right click copy the path and now instead of just gpx.fmt we're going to actually give it the full path to where that is located so c gpx.fmt so all right so we're saying exif tool use this dash p command which means print format what format do you want to print in print it in this gpx format and what all data do you want to get use this extract embedded to get the information and then that's the file so if we try this remember since we took away the piping of it to a file it's just going to print on our screen but that's fine for now let's just make sure it looks right so if i paste that hit enter we should see it you can ignore these little warnings here but you see it's coming back in a totally different format it's this xml like doc document here so that's cool so now the next logical thing would be to pipe it to a file so then we can drag it into a geospatial program like qgis so i'm just going to add the pipe or the greater than sign and same thing i did earlier i'm going to copy this same path and we're just going to change the extension or change the file name so instead of that input movie we're going to say gpx sample.gpx all right so again let's just look over this really quick before we run it so the first parameter is the actual tool then we're saying dash p for print format and then we're supplying it with the format file gpx then we're saying dash ee extract all this metadata from this file and then we're saying anything that you normally would have printed on the screen pipe it out to this file all right so clear the screen again and now let's run it hit enter all right you can ignore these warnings and now if we look in our folder here we see a gpx file right here so that's good so let's just open it up with whatever you want to open it i'm going to open it with visual studio code but you know notepad notepad plus plus it's just a text document so you see here we have all the data and that's looking good i'm actually i have this tool called um geodata viewer so it allows you to work with gpx files it actually lets you plot it on a map so i would recommend searching for this in the extensions and just installing it because you can do cool things like view a map because it's a geospatial file it knows how to position it on this map usually it loads a little faster i think it's because i'm on a windows server machine or something but you see here here is where this actually took place in the real world and this was just a one minute video clip so that's why it's a pretty short distance here but yeah that that's uh how it works it's pretty cool and just the last thing i want to test is to make sure that this gpx file can be brought into qgis make sure there's no formatting issues with this or anything for example if like this was missing a bracket or a slash like that there'd be a syntax error and this just wouldn't work in qgis but let's give it a try so i'm just gonna drag that file that gpx file into qgis all right so it's it found some information so it's there's 59 point features so just hit ok and there you go that's where this took place in the real world and yeah that's how you can pretty easily extract metadata from a mp4 file so i know like gopro does this a lot of other people do this and it's pretty useful to be able to uh to do this um what i did so my dash cam recorded one minute videos i actually wrote a python script that basically just calls this exact command right here but it uses variables because the movie so imagine having 3 000 mp4 files basically what the python script did was just loop through all the files and ran it with this as a different as a variable so video one would be here on the first loop video two would be here on the second loop and what i ended up with was a bunch of gpx files so i can show you what i'm talking about here so these were all the different days we traveled and you can see there's a gpx file next to each mp4 file so that was because i ran a python script um and yeah if anyone's interested in seeing how i did that uh let me know i can make a quick video it's literally it was just a for loop through a folder with this command being called in python uh if that makes sense but yeah uh thanks for watching uh if you like this give it a thumbs up or subscribe if you want and i'll see you in the next video thanks hey guys so i just forgot one thing i wanted to share i wanted to show you how you can convert an entire directory of mp4 files to gpx files with one command so i'm just going to copy two more multiple there we go i'm just going to copy two more of these mp4 files to my working directory so let me paste these so we have a total of four mp4 files and then i'm going to show you the command that will allow it to convert all of them to gpx so let me just get rid of the files i don't want right now we just want to have mp4s here uh that's because it's open all right close that try again okay keep the gpx.fmt don't need this don't need this oh wait i thought i had four of them copied uh i guess not doesn't matter all right so the command we need it's a new command it's dash w so let's look at the documentation here and dash w is text out so right or overwrite output text files all right so what we're going to do is i actually have an example somewhere all right so that's what the sample looks like so we already have dash p e dash ext mp4 okay so we need to add this to our command so after we have dash ee just add dash extension mp4 this will make basically make it so it only looks at mp4 files and now we have to add this dash w so dash w and now we need to give it the where we want the output gpx files to go so i'm going to copy our normal location here paste that in and we need to actually give it this thing right here so this is basically using a variable to name the gpx file every time so that's what this little symbol is so paste that i think it's using the file name the input file name and then just adding gpx to it if that makes sense and then we just need and out the input directory okay so the input directory is so we're going to get rid of the piping because we're going to have the tool do it for us the input directory is that location all right does that look good let's just double check it so we have the executable dash p yep that's g dash w there's an extra space there dash w so it's basically output files input directory alright so let's try this copy clear the screen run that okay that doesn't look good oh it's probably because those slashes let me try i have a feeling it might have to do with these slashes oh actually i meant to do it on this one let's try this why is it not finding any mp4 files oh it's because i have they're capitalized mp4 files all right it's no big deal mp4 no wasn't it actually am i giving it the right folder except tool example maybe i don't need this there we go so i guess i had for some reason it doesn't want to have an extra slash on that so it's kind of weird just keep that in mind if it's not working for you right away it probably has to do with your paths or quotes things like that so now we saw what it said one one directory scanned three image files red three output files created so now if we go to that directory you see each one got this gpx file made so that's a quick handy way if you had like thousands or hundreds of thousands of mp4s and you just wanted to process all of them and make a gpx file this tool can make it easier for you instead of having to do it one by one um so let's just make sure these work in qgis but you know they should but just as a sanity check we will double check all right let's try this first one all right that looks good cool try one more just for kicks all right okay now i picked some random files so select all they're probably not going to be oh i guess they are right next to each other anyway uh that's what i wanted to share that is that's more useful than what i should before just one at a time this is actually if you wanted to do a whole directory but yeah hope that was helpful and thanks for watching
Info
Channel: franchyze923
Views: 448
Rating: 5 out of 5
Keywords: exiftool, gis, qgis, arcgis, mp4, gps, gps mp4 file, extract gps from mp4, mp4 extract metadata, mp4 metadata, go pro metadata, go pro mp4 metadata, python, command line, command line interface, cli, windows cli, shapefile, kml, kmz, gpx, GPX, .GPX, gpx file, embedded metadata, meta data
Id: Uje5si23lBk
Channel Id: undefined
Length: 19min 35sec (1175 seconds)
Published: Mon Aug 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.