Can I change Make & Model without concern

Started by worx, November 15, 2020, 04:02:41 PM

Previous topic - Next topic

worx

Hi,

My photo/video collection spans many years and many different consumer cameras. Unfortunately that also means different formatting of Make and Model names etc. I was working on a command line that would change the model naming from i.e. 'PENTAX' to 'Pentax' but got a warning message "Warning: [minor] Maker notes could not be parsed". On further investigation I found a note in the faq that recommended "So it is a good idea not to edit the Make and Model tags in the first place.". I wanted to check whether that warning applies all camera types or more pro cameras as I can't quite understand how changing the Maker name from one to another would have any impact.

Only reason I want to change the make & model formatting/naming is in order to make it easier (and to automate) the renaming of the files as they get uploaded onto my Synology. Is there an alternative route I should explore?

Thanks for the support.

StarGeek

Quote from: worx on November 15, 2020, 04:02:41 PMI wanted to check whether that warning applies all camera types or more pro cameras as I can't quite understand how changing the Maker name from one to another would have any impact.

Camera makers constantly change the format of the files their cameras create.  A certain value may be at location X in one camera, but at location Y in another.  Changing the Make and Model means that programs that need to read this information will not be able to find it.

If you don't care about the MakerNotes and your images are all jpegs, then you don't need to worry about it.  Jpegs will render properly no matter what value is in the Make and Model.  But if you think you might get more interested in the technically info that's in the MakerNotes or it your files are RAW files of any sort, then you do not want to edit these tags.  In the case of RAW files (.CR2, .NEF, .ORF, etc) especially you don't want to change these tags as that information is vital in order to decode the file and render the image.

Quote from: worx on November 15, 2020, 04:02:41 PMIs there an alternative route I should explore?

You could always repurpose a different, less commonly used tag to do this.  For example, unless you upload your images to GettyImages.com, there's the XMP-getty:CameraMakeModel tag.  It's unlikely to used by any program outside of the Getty website and would be ignored.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

worx

OK, noted. As I want to automate much of this and want to keep the risk to a minimum I will look at re-purposing option.

Many thanks StarGeek. I am sure I will be back with more questions.

worx

Hi,
I decided to experiment with custom tags as this this seems to be the safest option. So I set up .ExifTool_config and added three new tags:

        SynologyPhotoTagMaker => { Groups => { 2 => 'Author' } },
        SynologyPhotoTagModel => { Groups => { 2 => 'Author' } },
        SynologyPhotoTagWhatsApp => { Groups => { 2 => 'Author' } },

I run the following command:
exiftool -config /volume1/@appstore/ExifTool/.ExifTool_config -if '$make eq "Google"' -v2 -SynologyPhotoTagMaker=Google -r [File]

That seems to work as expected although I am a little surprised about the update process:

Writing XMP-xmp:SynologyPhotoTagMaker
======== 2020.10.20-11.45.22-Pixel_2_XL.Google.jpg
Rewriting 2020.10.20-11.45.22-Pixel_2_XL.Google.jpg...
  Editing tags in: APP1 XMP
  Creating tags in: APP1 XMP
JPEG APP1 (23732 bytes):
JPEG APP0 (14 bytes):
JPEG APP1 (3129 bytes):
  Rewriting XMP
    + XMP-xmp:SynologyPhotoTagMaker = 'Google'
JPEG APP2 (610 bytes):
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG SOF0:
JPEG DHT (29 bytes):
JPEG DHT (179 bytes):
JPEG DHT (29 bytes):
JPEG DHT (179 bytes):
JPEG SOS
    1 image files updated

As somewhat expected I guess, I now have some questions around all this which I hope you can guide me through:
1. Does the command line look about right to achieve => Check whether Google is present in Maker Tag => if 'Google' is present in 'Maker' Tag, add 'Google' to 'SynologyPhotoTagMaker' Tag?
2. What does the '-v2' stand for in the command line? Only info I could find was this "to also list the Perl include directories" and I don't really know what it means. Do I need it?
3. Do I need to be concerned about all the additional info provided during the update process? (JPEG APP1, etc ..)
4. I don't really know what I added to the .ExifTool_config file as I just copied and adjusted the sample code. Any chance you could explain to me in simple terms what the purpose of 'Groups', '2' and 'Author' is in the that line?
5. At the moment Exiftool creates a copy '_original'. Is '-overwrite_original' the right command to use to not have a copy created?

Again my thanks to anyone who can provide me with some guidance.

StarGeek

Quote from: worx on November 17, 2020, 04:17:19 PM
1. Does the command line look about right to achieve => Check whether Google is present in Maker Tag => if 'Google' is present in 'Maker' Tag, add 'Google' to 'SynologyPhotoTagMaker' Tag?

That command doesn't check to see if the word "Google" is present in the Make tag, it checks to see if Make is exactly equal.  It would not match "google" or "Great Google App".  If you want to match "Google" anywhere in the tag, then you would want to use either RegEx, e.g. -if '$Make=~/Google/' or the Perl index function, e.g -if 'index($Make,"Google" )!=-1'.  These examples are Case Sensitive.  To be case insensitive in the case of the RegEx you would add an i after the last slash.  In the case of index you would use the uc or lc to convert the Make to either Upper/lower case before comparing.

Quote2. What does the '-v2' stand for in the command line? Only info I could find was this "to also list the Perl include directories" and I don't really know what it means. Do I need it?

See the -v (-verbose) option.  It's not needed, it just shows you everything exiftool is doing.

Quote3. Do I need to be concerned about all the additional info provided during the update process? (JPEG APP1, etc ..)

For the most part, no.  Exiftool will only change what you tell it to in nearly all cases.  But there are some tags that will affect more than one tag at a time (AllDates for example) and there are probably some edge cases I can't think of atm.

Quote4. I don't really know what I added to the .ExifTool_config file as I just copied and adjusted the sample code. Any chance you could explain to me in simple terms what the purpose of 'Groups', '2' and 'Author' is in the that line?

If you're just using a simple string, you can drop the part between the braces. Just SynologyPhotoTagMaker => { } }, should work.  That inner part is adding it to the Author category.  If you run a command like exiftool -G1 -a -s -Author:all file.jpg, you will see all Author category tags in the file.  See the docs on the GetGroup() function for more details.  For fun, you can use something like exiftool -Author:all=Test Test.jpg and see everything that will get filled under the Author group.  My quick test showed it filled out 155 different tags.

Quote5. At the moment Exiftool creates a copy '_original'. Is '-overwrite_original' the right command to use to not have a copy created?

Yes, see the -overwrite_original option.  There is also the -overwrite_original_in_place option which will write the edited file in a different way, but that is slower and really isn't need except in cases where there is filesystem data attached to the file that you don't want to lose.  Usually it's Mac xattr data but would probably also include Windows Alternate Data Streams (which are pretty much never used).
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

worx

Thanks again for the prompt reply StarGeek. I will make some adjustments and move to the next step.

worx

Right, I am back with some more questions. Have been working away on automating this whole process.

1. When I follow your suggestion as per No 4 and add SynologyPhotoTagMaker => { } } to the .ExifTool.config file I get this error message:

Unmatched right curly bracket at /volume1/@appstore/ExifTool/.ExifTool_config line 115, at end of line
syntax error at /volume1/@appstore/ExifTool/.ExifTool_config line 115, near "}"
Can't redeclare "my" in "my" at /volume1/@appstore/ExifTool/.ExifTool_config line 226, near ""
syntax error at /volume1/@appstore/ExifTool/.ExifTool_config line 238, near "}"
BEGIN not safe after errors--compilation aborted at /volume1/@appstore/ExifTool/.ExifTool_config line 303.
Warning: Tag 'SynologyPhotoTagMake' is not defined
Nothing to do.


2. When I use this command line below I get an error. Why? Considering I am only making changes to custom Tags this shouldn't really have any impact on MakerNotes:

exiftool -config /volume1/@appstore/ExifTool/.ExifTool_config '-SynologyPhotoTagMake<Make' '-SynologyPhotoTagModel<Model' [Source Directory]

Warning: [minor] Unrecognized MakerNotes - /volume1/photo uploads/testfolder/IMG_20200808_140607_1.jpg
Warning: Error rebuilding maker notes (may be corrupt) - /volume1/photo uploads/testfolder/IMG_20200808_140607_1.jpg


3. I am struggling to put together a command line that would allow me to do the below. Is this even possible?
=> move files in [source Directory] to [final Directory] => if file already exists with same file name move to [alternative Directory]

By the way, what is the best practice here in this forum, to create a new post for every new topic or to just keep sticking to the existing thread and to adapt the header to incorporate the overall topic.

Any help/pointers are appreciated. Thanks


StarGeek

Quote from: worx on November 20, 2020, 09:02:52 AM
1. When I follow your suggestion as per No 4 and add SynologyPhotoTagMaker => { } } to the .ExifTool.config file I get this error message:

Unmatched right curly bracket at /volume1/@appstore/ExifTool/.ExifTool_config line 115, at end of line
<snip...>

Ooops, my mistake.  Didn't edit out the extra brace when I copy/pasted.  As it says, drop one of the closing braces.

Quote2. When I use this command line below I get an error. Why? Considering I am only making changes to custom Tags this shouldn't really have any impact on MakerNotes:

See FAQ #15, specifically the last few paragraphs.  Camera makers are often really bad at inserting their MakerNotes into the EXIF block and a lot of editing programs are really bad at properly re-writing the EXIF block when there are MakerNotes.  Overall, this is a very common warning and usually won't affect anything.

Quote3. I am struggling to put together a command line that would allow me to do the below. Is this even possible?
=> move files in [source Directory] to [final Directory] => if file already exists with same file name move to [alternative Directory]

I don't think it's possible.  There's logic to fall back on previous directory changes if a tag doesn't exist, but my quick test shows you can't fall back on a previous change if the target file already exists.  The only real option here is the %c copy number option (see Advanced Features under the -w (textout) option).

QuoteBy the way, what is the best practice here in this forum, to create a new post for every new topic or to just keep sticking to the existing thread and to adapt the header to incorporate the overall topic.

It's pretty informal here.  I don't even read the headers to see if they change.  Overall, walls of text are bad.  The more excess information is given in a post makes it less likely to get answered.  We don't necessarily need the your whole origin story ;)
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

worx

Thanks for the continued support StarGeek. I will plough away with the new information. Thank you

worx

I am now trying to put together the various workflow steps into one Bash script and wondered if anyone knows how to optimise Bash scripts for Exiftool? For example I am referencing the location of the config file in every line, but can I set this only once at the beginning of the script?

I.e. exiftool -config /volume1/@appstore/ExifTool/.ExifTool_config -directory=/volume1/'photo uploads'/automation/sortingFolder -ext jpg -ext mp4 -m /volume1/'photo uploads'/testfolder can I make the script more efficient by not having to repeat this snippet over and over again: -config /volume1/@appstore/ExifTool/.ExifTool_config'

What about other file locations, can they be defined at the beginning of the bash script? I am working with a Synology Server so Linux.

Thank you

StarGeek

#10
You do not need call the .exiftool_config file as long as it is in one of the directories that exiftool will search looking for it.  See the 3rd paragraph under "Notes: in the example.config file.

Edit: removed extraneous bracket
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

worx

Yea, good point. Initially I had the Synology Exiftool app installed and had issue finding the exiftool home directory. You inspired me to fix that so uninstalled the app and installed the library. Had some permission issues at first when using exiftool as non-root, but fixed that now as well. Now to cleaning up the code  :-\

worx

And I am back with more questions  :-[ I would categorise them as a little odd.

1. I use the following command to create the CreateDate from the filename in this naming format VID-20180408-WA0005.mp4
exiftool '-createdate<${filename;$_=/(\d+)/ ? $1 : undef} 00:00:00' -if '$SynologyPhotoTagOther eq "WhatsApp"' -ext mp4 VID-20180408-WA0005.mp4
Problem is that on this file "VID-20190331-WA0000.mp4" the CreateDate does not get create. the output is:
1 directories scanned 0 image files read
It seems very random as the file names are pretty much the same. I used '-alldates<filename' on this file and that created the CreateDate correctly for "VID-20190331-WA0000.mp4" the. Any thought on this?

2. When I use
exiftool -if '$filename=~/^PXL_\d{8}_\d{9}\.\w*/' -SynologyPhotoTagMake='Google' -SynologyPhotoTagModel='Pixel 2 XL' -SynologyPhotoTagOther='MP4' -ext mp4 PXL_20201120_163528123.mp4
I seem to be getting a random error message:
Error: No data reference for sample description 0 for Track1 - PXL_20201120_163528123.mp4
This file however should be no different to other files where the above command work just fine. I also don't understand the error message so don't even know where to start.

Many thanks

StarGeek

Quote from: worx on December 02, 2020, 04:04:14 PM
1. I use the following command to create the CreateDate from the filename in this naming format VID-20180408-WA0005.mp4
exiftool '-createdate<${filename;$_=/(\d+)/ ? $1 : undef} 00:00:00' -if '$SynologyPhotoTagOther eq "WhatsApp"' -ext mp4 VID-20180408-WA0005.mp4
Problem is that on this file "VID-20190331-WA0000.mp4" the CreateDate does not get create. the output is:
1 directories scanned 0 image files read

There's a discrepancy between your command and your output.  You say that you are processing a single file, but the output says exiftool is trying to process a directory.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

worx

Quote from: StarGeek on December 02, 2020, 04:40:04 PM
Quote from: worx on December 02, 2020, 04:04:14 PM
1. I use the following command to create the CreateDate from the filename in this naming format VID-20180408-WA0005.mp4
exiftool '-createdate<${filename;$_=/(\d+)/ ? $1 : undef} 00:00:00' -if '$SynologyPhotoTagOther eq "WhatsApp"' -ext mp4 VID-20180408-WA0005.mp4
Problem is that on this file "VID-20190331-WA0000.mp4" the CreateDate does not get create. the output is:
1 directories scanned 0 image files read

There's a discrepancy between your command and your output.  You say that you are processing a single file, but the output says exiftool is trying to process a directory.

Thanks StarGeek
You are of course correct. I got a bit sloppy when removing the folder structure in order to simplify the command for posting. As I was rechecking I also noticed another error - I got the extension wrong in the command that I tested (was jpg instead of mp4). I thought I had already tested that but after reviewing my long list of tests it seems I never did. So point one is resolved - my apologies. Point 2 however is still open and puzzling.

StarGeek

That is probably an actual problem with the file structure.  I can only find one other time it's been mentioned here and that person never followed up. 

Phil will have to comment on this.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

worx

#16
I did some more testing and it seems as if the problem sits with the mp4 files themselves. The mp4s I have been testing with are from the new Pixel 4a 5G and looking at what was written about metadata and video files I suspect Google devs have broken/changed something.

To give some details - I can get the info out for i.e. 

exiftool PXL_20201203_110732369.mp4

but can't make changes to the i.e. CreateDate or Make or any of the custom Tags I use for all the other files.

Phil Harvey

Quote from: worx on December 02, 2020, 04:04:14 PM
Error: No data reference for sample description 0 for Track1 - PXL_20201120_163528123.mp4

I downloaded a Pixel 4a sample and it looks like I have some work to do here.  These videos use a new format that I haven't seen yet for the sample entries in the sample table box.  It looks like this may be allowed by the specification, but it also looks like it may be a real pain to deal with.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

worx


Phil Harvey

[This is more for my reference than anything else...]

After studying the specification more closely I am convinced that the Pixel 4 writes the sample table box incorrectly.  According to the specification, each SampleEntry must begin with 6 zero bytes followed by a 2-byte data_reference_index.  I found the specification for the 'mett' sample entry used by the Pixel 4, and it extends the basic SampleEntry thus (from the ISO_IEC_14496-12 specification):

aligned(8) abstract class SampleEntry (unsigned int(32) format)
   extends Box(format){
   const unsigned int(8)[6] reserved = 0;
   unsigned int(16) data_reference_index;
}
class MetaDataSampleEntry(codingname) extends SampleEntry (codingname) {
   Box[] other_boxes; // optional
}
class TextMetaDataSampleEntry() extends MetaDataSampleEntry ('mett') {
   string   content_encoding; // optional
   string   mime_format;
   BitRateBox ();    // optional
   TextConfigBox (); // optional
}


Therefore, each 'mett' MetadataSampleEntry must still begin with 6 zero bytes and a 2-byte data_reference_index.  However, the Pixel 4 skips this and jumps straight to the content_encoding string, which is clearly wrong:

  | | | | + [SampleTable directory]
  | | | | | MetaSampleDesc (SubDirectory) -->
  | | | | | - Tag 'stsd' (50 bytes):
  | | | | |  1f4b07a: 00 00 00 00 00 00 00 01 00 00 00 2a 6d 65 74 74 [...........*mett]
  | | | | |  1f4b08a: 61 70 70 6c 69 63 61 74 69 6f 6e 2f 6d 65 74 61 [application/meta]
  | | | | |  1f4b09a: 00 61 70 70 6c 69 63 61 74 69 6f 6e 2f 6d 65 74 [.application/met]
  | | | | |  1f4b0aa: 61 00                                           [a.]


(The first SampleEntry starts immediately after the 'mett' identifier in the above exiftool -v3 output from a Pixel 4 video.)

Since the data_reference_index is needed to be able to rewrite the file properly, ExifTool can't edit these files without risk of further damage.  Google will have to fix this at their end.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

worx


worx

I have another question:

I am using this command
exiftool '-createdate<${filename;$_=/(\d+)/ ? $1 : undef} 00:00:00' -if '$SynologyPhotoTagOther eq "WhatsApp"' -ext jpg -ext jpeg /volume1/'photo uploads'/automation/sortingFolder to rename WhatsApp files:
=> Input: 'IMG-20201201-WA0001.jpg'
=> Output: '2020.12.01-00.00.00-1-WhatsApp' (if there are two files)

I would like to improve this command, if it is simple enough to maintain. At the moment this command sets the HH:MM:SS to '00:00:00' on every file. What I would like it to do is use the numbering after the 'WA' i.e. 0001 in this example IMG-20201201-WA0001.jpg as the MM:SS. I would like the output to look like this sample:
=> Output: '2020.12.01-00.00.01-WhatsApp'

Is this easily achievable? Thanks

Phil Harvey

This won't work the way you are thinking. What happens if the number is WA0060?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

worx

The day I will get 60 pictures in via WhatsApp will be a sad day  ;D

I get your point though that this isn't an easy one to implement and far from essential.

Thanks for the feedback Phil,

Phil Harvey

OK, try this:

exiftool '-createdate<${filename;$_=/(\d{8}).*(\d{4})/ ? "$1 00:$2" : undef}' -if '$SynologyPhotoTagOther eq "WhatsApp"' -ext jpg -ext jpeg DIR

This will do what you wanted when writing CreateDate.  But I'm a bit confused.  Are you talking now about changing the FileName?  Your example implies this, but unless I missed something you didn't mention this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).