Actually executing exiftool.exe from C# code, would like to do better #449
Replies: 6 comments
|
This may not be as easy as you think. The approach I would take:
|
|
You might also find that Phil has done the hard work of decoding these files and simply calling Exiftool from your code is the best approach. The CanonModelID is a perfect example - if you take on the decoding in your program then you are also going to have to update it when Canon releases a new camera model. |
|
The is a C++ wrapper for exiftool here |
|
Now that I am no longer on mobile, I can provide more info. @amluk is correct. Phil Harvey (@boardhead) has put a tremendous amount of work into deciphering these obscure metadata tags that the camera manufacturers don't document and often obfuscate. You won't find any other tool that deciphers as much metadata from so many file types. As for where to start, you would start with finding the tag name (not description) as @amluk suggests. You would use a command like this
Then you would look in the source code in /lib/Image/ExifTool, specifically targeting the Canon based files. From there, you should be able to find out where the tag name is in the code and what you need to do to extract it. Then the problem would be finding the proper block in the MP4 file. You could try and do a simple search for it, but there isn't a way to know exactly where it is located in the MP4, because MP4 files can have the metadata at the beginning or at the end of the file. And you don't want to bulk search through all the actual video/sound streams. You would want to parse the MP4 streams so you can skip over that data quickly. |
|
Thanks a lot for all your thorough answers! I'm already calling exiftool.exe from C# code (only for the .mp4 files so far, as image files have tags I can easily access with native Microsoft .NET libs already) and I will indeed not try to delve further into this. I will probably finally also use exiftool for image files also. (For the record, I started all of this because my Canon cameras couldn't name image/video files with names of the form yyyyMMdd_hhmmss_{camera model}.JPG for instance ... (Which is still a pity in 2026 ...) |
|
I should point out that you do not want to call exiftool once per file, especially if you are processing a lot of files. See Common Mistake #3, "Over-scripting". Exiftool's startup time is its biggest performance hit. You probably want to take a closer look at the C++ wrapper I linked above. It uses exiftool's Unfortunately, I can't provide any better links because the exiftool forum has been knocked offline because AI bots kept scraping the forum hard and the web host (Dreamhost) took the site down for too much traffic. |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I needed to extract information from files produced by Canon cameras. I had no problems with RAW .CR3 files nor with .JPG, they had what I needed (the Canon Camera Model "field") and native Microsoft C# APIs made my day. Remained video .MP4 fies. Nothing worked, I teste almost everything and no C# (nor C/C++)) libraries that I came across (I may not have been exhaustive, I am human! :) ) failed to provide the required Canon Camera Model "field".
I finally came across your command line tool, the exe, that I am simply calling from my C# code, getting the XML outputting and parsing. It is fun but I would prefer to avoid that, so that I would like to understand how you manage to extract that much info with Perl, and if you could point me to the place in the code where it is done, I would like to, to see if I could adapt it, in C for instance.
Kudos for you amazing work and thank you in advance!
All reactions