Hi. I have a wondering if it,s possible to use a wildcard command with exiftool and add the timecode tag following a sequential numbering? I have a syntax that goes like this.
find . -maxdepth 1 -mindepth 1 -name '*.DNG' -print0 | xargs -0 exiftool "-TimeCodes=00:00:00.00" -overwrite_original
Now the problem is I need a way to add the correct timecode sequential number derived from fps and the amount of dng files. It should go something like this. TimeCodes=00:00:00.01, TimeCodes=00:00:00.02, TimeCodes=00:00:00.03 etc.
Firstly I wonder if it is possible to alter numbers at all sequentially from within exiftool or if there is any other way to do this? I,m thinking something in the line like this maybe?
"-TimeCodes=_%06d"
Thanks Phil for this awesome altering tool. Invaluable.
There is a way to do this with normal date/time tags by shifting them sequentially by the value of the FileSequence tag. The TimeCodes are unfortunately not shiftable. But the following technique will work for the first 100 files:
exiftool '-timecodes<00:00:00.$filesequence' -ext dng -r -overwrite_original DIR
To go beyond this it would be best to create a user-defined Composite tag based in FileSequence to format the time code however you want.
- Phil
Thanks for the tip! I get back as soon as I have this functioning. Have a great day.
Hi Phil. Trying out your filesequence command that is supposed to go all the way to 100. It seems the range goes between 01-39 then starts over from 00? Am I missing something? On another note I would like to ask if it,s possible to alter filesequence range? If so it could be possible to have let,s say 24fps range between 0-24 instead of 1-100. I,m trying to grasp the user-defined Composite tag which I assume could achieve this but I would really need a push in the right direction to be able to go further.
I,m using this version for mac.
ExifTool Version Number : 10.05
Following syntax
exiftool '-timecodes<00:00:00.$Filesequence' *.dng -overwrite_original ;
Following two files are part of a longer dng sequence.
ex
M23-1046_1_2015-12-23_0001_C0000_000039.dng
Time Codes : 00:00:00.39
Suddenly back to zero
M23-1046_1_2015-12-23_0001_C0000_000040.dng
Time Codes : 00:00:00.00
Honestly, I don't remember all of the details of the TimeCodes tag format (and reading the specification quickly doesn't help). I was assuming that the decimal was fractional seconds, but it seems that is not the case.
The attached config file will increment the decimal value from 0-23 then increment the seconds, then the minutes, etc, with a command like this:
exiftool -config mytimecode.config -api requestall '-timecodes<mytimecode' -ext dng -overwrite_original DIR
Note that the API RequestAll option must be set for the FileSequence tag to be generated since it wasn't requested explicitly on the command line.
- Phil
Edit: Oops. Changed "<=" to "<" in config file
That is a exactly what I was looking for. Didn,t understand how to use the config file before. Great function.
Now to the problem. For 24 fps it is great. Of course I tried to modify the config file and set number 24 to 50 and it still resets at 39 and goes back to zero which leaves timecodes out in the cold for footage shot in 50 or 60fps.
Not sure I follow this and I assume the answer lies in this sentence.
QuoteI was assuming that the decimal was fractional seconds, but it seems that is not the case.
My intention is to use this in dng files coming from magic lantern processed files in an open source project called MLP.
Thanks again for your great exiftool. Use it all the time.
The timecode is not stored as a simple string. I don't recall what the number after the decimal point is for, and what range of values it can take, and I don't have time to re-read the specification in detail right now, but it is here (http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/cinemadng/pdfs/CinemaDNG_Format_Specification_v1_1.pdf) if you want to have a go.
- Phil
Thanks, I,ll do my research. I checked with another application and it seems the behaviour is the same as with the config file(reset after 39). Maybe all is in order. Assumed it was following fps but that might not be the case here.
Hi Phil. Been reading a lot about timecode and tested out an implementation which kind of works but it doesn,t fully follow the standard timecode procedure(smpte). Altough not many people find it useful my aim is to have a correct timecode clock inserting the correct number derived from the frames per second filmed.
Tried understanding the cdng spec but I have a real hard time understanding what it,s all about. What I could find out about is how timecode works and why it is used. Long story short. This is my implementation using your config file syntax.
if grep '23\|24\|48' /tmp/magic_l_prores/fps_RAW
then
fps=$(echo 24)
elif grep '25\|50' /tmp/magic_l_prores/fps_RAW
then
fps=$(echo 25)
elif grep '29\|30\|60' /tmp/magic_l_prores/fps_RAW
then
fps=$(echo 30)
else
fps=$(echo 30)
fi
#config code coming from Phil Harvey himself, author of exiftool
echo "%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
MyTimeCode => {
Require => 'FileSequence',
ValueConv => q{
my @a = (0,0,0,\$val);
my @mx = (0,59,59,$fps);
for (my \$i=3; \$i>0; --\$i) {
next if \$a[\$i] <= \$mx[\$i];
\$a[\$i-1] += int(\$a[\$i] / \$mx[\$i]);
\$a[\$i] %= \$mx[\$i];
}
return sprintf('%.2d:%.2d:%.2d.%02d', @a);
},
},
},
);
1; #end" > mytimecode.config
There really only are three timecode framerates that will be set here. The 24, 25 or 30fps. The way it works with exiftool is that the file sequence created runs in sequences going from 01-24 or 01-25 or 01-30 depending what framerate will be chosen. Now if we check a timecode generator like this https://www.youtube.com/watch?v=3bQFdJ5cZw0&feature=youtu.be
We see that the range will start and end like this 00-24 for PAL and 00-29 NTSC(I left out any frame drop implementation). This gives the relationship in range like this which seems the correct way to do it.
24(23.97)fps 00-23
25fps 00-24
30(29.97)fps 00-29
With existing exiftool config file the relationship is like this
24(23.97)fps 01-24
25fps 01-25
30(29.97)fps 01-30
My question is if the FileSequence function could be set to 00 after starting over instead of starting at 01 thus following the standard timecode procedures?
QuoteThe attached config file will increment the decimal value from 0-23 then increment the seconds, then the minutes, etc, with a command like this:
It does this but only the very first file will have the 00:00:00,00 number. The rest will start off with 00:00:01,01.
I use a syntax like this.
find . -maxdepth 1 -mindepth 1 -name '*.dng' -print0 | xargs -0 exiftool -config mytimecode.config -api requestall '-timecodes<mytimecode' -overwrite_original ;
Hmm, did some more tests. It seems only the problem is in the very start. Checking the first 26 files reports different from the following sequenced timecode numbers. I tested footage shot in 24fps and it apply timecode numbers the following way.
The config script looks like this
echo "%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
MyTimeCode => {
Require => 'FileSequence',
ValueConv => q{
my @a = (0,0,0,\$val);
my @mx = (0,59,59,24);
for (my \$i=3; \$i>0; --\$i) {
next if \$a[\$i] <= \$mx[\$i];
\$a[\$i-1] += int(\$a[\$i] / \$mx[\$i]);
\$a[\$i] %= \$mx[\$i];
}
return sprintf('%.2d:%.2d:%.2d.%02d', @a);
},
},
},
);
1; #end" > mytimecode.config
First 26 frames looks like this:
The very first dng file is numbered 00:00:00.00 correctly
first frame=00:00:00.00
Then moving to frame 23-25:
the 23d frame=00:00:00.22 (should be 00:00:00.23)
the 24th frame=00:00:00.23 (should be numbered 00:00:01.00)
the 25th frame=00:00:00.24 (should be numbered 00:00:01.01)
It is like it doesn,t count for the very first frame of the sequence and it doesn,t either turn to zero after coming to the 24th frame in the very first second of the footage. This seems to make the whole processing go wrong with one frame lost in the whole timecode sequence
However
Then things start to get going as it was thought to.
The 26th file is now getting the number 00:00:01.01
The 49th file is getting 00:00:02.00
Between 49-72 we have exactly 24 frames and it shows correctly
frame 49=00:00:02.00
frame 72=00:00:02.23
Following 24 frames 73-96 also correct timecode
73=00:00:03.00
96=0:00:03.23
Sorry bout all the fuzz here. Some more narrowing down. My math brain isn,t so fast.
What it boils down to is that only one frame will be having to change. Namely the first frame of the of the second dng range. In this case when filmed in 24fps it should look like this.
Frames(to the left) and timecodes(to the right).
00-23=00:00:00.00 - 00:00:00.23
24-47=00:00:01.00 - 00:00:01.23
48-71=00:00:02.00 - 00:00:02.23
72-95=00:00:03.00 - 00:00:03.23
But it looks like this
00-23=00:00:00.00 - 00:00:00.23
24-47=00:00:00.24 - 00:00:01.23
48-71=00:00:02.00 - 00:00:02.23
72-95=00:00:03.00 - 00:00:03.23
Sorry about the bug in my config file. I put a "<=" where I should have had "<". I've updated the attachment in my previous post to fix this. Your fix to change the "60" to "59" would cause problems like what you are seeing.
- Phil
Thanks a lot Phil. It worked perfectly. Had just created a fix for that one bugging file but now with the fixed config file it is beautiful.
I have one more question. However unlikely filming up to an hour continuously with magic lantern raw footage due to its size but how do I understand this line?
my @mx = (0,60,60,24);
Is the 0 gonna turn to 1 when filmed for one hour? 0=hours, 60=minutes, 60=seconds, 24=frames?
Does it makes sense to write like this
my @mx = (23,60,60,24);
or even better maybe
my @mx = (24,60,60,24);
Once again, thanks for your amazing tool and for creating the config file.
Great. The first zero in the @mx array is just a placeholder, and isn't used because the loop only goes down to 1 ($i > 0). So the number of hours would increment without limit, but you would need to have an incredibly large number of images to run into problems with this. The hours seem to be able to go up to 39, so you are OK up to 3456000 images (40 * 60 * 60 * 24 = 3456000, assuming 24 fps).
The hours seem to be able to go up to 39, so you are OK up to 3456000 images (40 * 60 * 60 * 24 = 3456000, assuming 24 fps).
Sounds very nice to me.
Thanks!
Incredible Progress @Danne and much THANKS to the great @Phil Harvey ... You have just made his app so much better and more precise with your assistance!