How to use Exiftool with Python

Поділитися
Вставка
  • Опубліковано 13 січ 2025
  • Learn how to extract GPS Metadata from an .MP4 video file and create a .GPX file using the free and open source tool, Exiftool with Python!
    Code - github.com/fra...
    exiftool.org/
    Documentation - exiftool.org/e...
    location of gpx.fmt file:
    github.com/exi...
    ___________________________________________________________________________
    GitHub - github.com/fra...
    Instagram - / franchyze923
    Twitter - / franchyze923
    Discord - / discord

КОМЕНТАРІ • 27

  • @johntamplin
    @johntamplin 2 роки тому

    So, I'm happy to acknowledge that this did address my need (eventually), using exiftool from within Python. But mainly this video shows how to use python to traverse files in folders and sub-folders, and call external apps/programs. The exiftool part doesn't start until about 12 mins into a 19 min video, and there's no discussion of how to extract *just* the GPS data, which has just been sent to a text file along with lots of other data. Not a bad video, just different from what I expected from the description.

    • @Franchyze923
      @Franchyze923  2 роки тому

      Glad it eventuality helped - Naming the video is always the hardest part!

    • @oneeyedphotographer
      @oneeyedphotographer 2 роки тому

      I the earlier part was useful to me, the exiftool information would have been way less useful to me without the preceding information.

  • @ContentsOfTable
    @ContentsOfTable 7 місяців тому

    I suggest using the Python Pathlib and Glob modules as alternatives for file and directory operations.

  • @CruiseW
    @CruiseW 3 роки тому +1

    awesome video you did a good job explaining everything, really appreciate the tutorial and your time!

    • @CruiseW
      @CruiseW 3 роки тому

      One thing I did change.
      .GPX in capitals doesn't work for me (I am using windows) Geo data viewer couldn't see the file I'm guessing? changing it to lowercase worked.

    • @Franchyze923
      @Franchyze923  3 роки тому

      ahh, yea I could see that being an issue. Glad you were able to figure it out.

  • @isaacyoung1868
    @isaacyoung1868 2 роки тому

    Just want to say.. it would be nice if the majority of the video was directly related to the video title. I think people might know the basic python coding by the time they get to your video
    The important information is starting at about 12:00

    • @oneeyedphotographer
      @oneeyedphotographer 2 роки тому

      I am not one of your "people," and as presented it satisfied your need and mine. I count it an all-round win.

  • @kb1376
    @kb1376 2 роки тому +1

    This is a great tutorial. However, I'm having some issues adapting it to my needs. I'd like to use the ExifTool to read the metadata and move pictures into different folders by date. If the folder is not there, then create the date folder. I'm not able to use pillow because pillow doesn't support Sony RAW (.arw). Would you be able to point me in the correct direction?

    • @Franchyze923
      @Franchyze923  2 роки тому

      Hmm, if you can share a sample I'll try to take a look. I would start with this - bhoey.com/blog/extracting-raw-photo-exif-data-with-python/
      Seems like this person is using the py3exiv2 package to work with Sony ARW files.

    • @oneeyedphotographer
      @oneeyedphotographer 2 роки тому

      I have been using a bash script under Cygwin on Windows to import my photos.. It uses the file creation date.
      I have configured Cygwin to mount under /mnt instead of the default.
      I look for /mnt/?/DCIM and run over every card I find.
      It falls under "Crude Hack," I am looking for a more reliable way of getting image creation. I have been wondering whether I need to use dcraw which does understand raw files and hack it into shape. It would replace exiftool.

  • @007hansen
    @007hansen Рік тому

    try print( f"{ my_var = }") and you will see both, my_var = %my_var%
    Also from logging import basicConfig, info, INFO
    and somewhere basicConfig(level=INFO)
    so you can do info( f"{blah = }") instead of print (and change the info to debug instead of commenting it out when you no longer need it).

  • @louannec2
    @louannec2 Рік тому

    How do I do this with 2 insv files that create a 360 video? The only way it works manually in cmd is with both files (frontview and backview). My question is, how do include both files in the python script?

  • @hamzadata
    @hamzadata 3 роки тому

    Nice video. Consider using Bash script for more native performance and experience!

    • @Franchyze923
      @Franchyze923  3 роки тому

      Thanks, yea bash script would be a good idea. Although I'll admit I'm much more comfortable with Python.

  • @AdamBarbeau1
    @AdamBarbeau1 2 роки тому +1

    Thank you for making this video! I'm very much a beginner with python so the instruction is very helpful.
    I'm using this as a jumping point for exporting exif data for RTK drone imagery - the process you showed creates one file containing the exif data for each .mp4 -- I would like to have the data in one single file (I'm saving it as a .csv instead of .gpx). Any thought of where to change the code to get it to export as one file?
    Thank you for the help!

    • @Franchyze923
      @Franchyze923  2 роки тому

      are you working with images or videos?

    • @AdamBarbeau1
      @AdamBarbeau1 2 роки тому

      ​@@Franchyze923 I'm working with .jpg images. I'm sort of hoping to save the exif data as a dataframe (each row being a different image) rather than the individual csv files. (The exif outputs I'm gathering are simply image name, lat long and altitude - those I have pulling just fine but are just saving 1 jpg to 1 csv.)
      If this is a longer answer than is worth putting into a comment section no problem! I can keep poking around - thanks for the quick reply!

    • @Franchyze923
      @Franchyze923  2 роки тому +1

      @@AdamBarbeau1 I think your best bet to accomplish this is to just use exiftool without python. It has built in capability to do this, if you give it a directory of images. For example just run the following command in your command prompt (replace the paths with your paths).
      exiftool -n -gpslongitude -gpslatitude -gpstimestamp -csv /Users/fpolig01/Videos/dashcam_footage/ > /Users/fpolig01/Videos/output2.csv
      /Users/fpolig01/Videos/dashcam_footage/ = path to a folder where you have images
      /Users/fpolig01/Videos/output2.csv = location where you want .csv output file to be created.
      If you want to use Python I would suggest the PIL library, which lets you interact with EXIF tags from images. I have some videos where I use Python and PIL to do this exact thing.
      ua-cam.com/video/aEEJTfHQBTU/v-deo.html&ab_channel=franchyze923
      github.com/franchyze923/Code_From_Tutorials/blob/master/Arcgis%20Scripting%20with%20Python%20Arcpy/Scripts/img_to_shp_vid_17.py
      Let me know if you have any issues!

    • @AdamBarbeau1
      @AdamBarbeau1 2 роки тому

      @@Franchyze923 Thank you for your input! Yeah I agree the best route might be using it in the cmnd line exactly how you have it written (Just trying to make an one stop process instead of two!) I'm actually working through a few of your playlists - they've been very helpful in learning. The PIL library seems really neat but my only hiccup is that the lat long and altitude are not pulling out all that well using PIL - I'm working my way through seeing if its just pulling it in a different format that I need to convert to what will work for me.
      Thanks for taking the time to respond to my comments!

    • @Franchyze923
      @Franchyze923  2 роки тому

      @@AdamBarbeau1 no problem! Let me know if you run into issues trying to get it working with PIL. I could try to take a look if you are able to pass a sample file over.

  • @sarangchahakar1519
    @sarangchahakar1519 2 роки тому

    Hey thank you very much for this video its very helpful.
    But unfortunately the output file did not include the metadata information, instead it repeats the fmt file location path.
    Can you please help me understand where am I going wrong?
    Also for windows when calling exiftool file we no more have to use the the path of exiftool instead just write exiftool and the gpx file is generated.
    Code for reference:
    import os
    import os.path
    import subprocess
    path = os.getcwd()
    filename = 'MP4_csv.py'
    file_path = os.path.join(path, filename)
    #print(file_path)
    fmtfile = input('Please write the name of fmt file with extension ')
    fmtlocation = os.path.join(path, fmtfile)
    exiftoolname = input('Please write the name of exiftool file with extension ')
    exiftoollocation = os.path.join(path, exiftoolname)

    videoname = input('Please write the name of video file with extension ')
    videolocation = os.path.join(path, videoname)
    isFile = os.path.isfile(videolocation)
    if os.path.isfile(videolocation):
    print('FIle exists')


    else:
    print('File does not exist')

    while os.path.isfile(videolocation) is False:
    videoname = input('Please write the name of video file with extension ')
    videolocation = os.path.join(path, videoname)

    full_gpx_path = videolocation.replace(".MP4", ".GPX")
    with open(full_gpx_path, "w") as gpx_file:

    exiftool_command = ["exiftool", "-ee", "-p", "fmtlocation", videolocation]
    subprocess.run(exiftool_command, stdout=(gpx_file))
    print(f"Successfully created: {full_gpx_path}
    ")
    I will be grateful to get a reply from you. Thank you

    • @sarangchahakar1519
      @sarangchahakar1519 2 роки тому

      Correction: I tried putting the direct fmt path in exitoolf_command and it worked but if I try to call 'fmtlocation' from above it does not accept. Can you please help me ?

  • @iditech
    @iditech 2 роки тому

    please add a link to your youtube video referenced in this tutorial

    • @Franchyze923
      @Franchyze923  2 роки тому

      what part in the video do I mention that?

  • @Franchyze923
    @Franchyze923  3 роки тому

    I say "basically" way too much 🤣