Welcome Guest

Pages: 1 2
Save modified tags to video file
UKenGBPostMay 8, 2020, 05:52
Advanced
Posts: 57
Registered:
April 30, 2020, 09:36
Hot topicSave modified tags to video file

Why does it take so long? Well, I know it’s because the entire file is being read and then written and with huge video files, this takes a long time. But why is Yate doing this? Why is it not simply editing the tag and updating that in-place, in the file?

While I know it is possible to do that, I have found other software I’ve used (Subler, exiftool) can edit video tags instantly - usually. But not always and I don’t yet know why that is.

Take Subler. Usually when I use it to edit tags in a video file (mp4), when I save the file, it is done faster than I can close the window/dialog. It is clearly just editing the tag in-place. But sometimes, it takes a long time to Save, obviously it is having to rewrite the whole of the file, including the massive video data part which has of course not changed.

With Yate, it seems to rewrite the whole file every time, although I could be wrong about that. I’ve just never seen it perform a quick save of a video file. So...

Whatever the software being used, why do some video files need to be completely rewritten when just editing a tag (or tags), whereas others just get the tag edited in-place, almost instantly. What is it about video file tagging that causes this diverse behaviour?

UKenGBPostMay 8, 2020, 06:34
Advanced
Posts: 57
Registered:
April 30, 2020, 09:36
Hot topicRe: Save modified tags to video file

Having just saved several video files after first editing with Yate (which took a long time), I then had to edit them again which was almost instant.

So, for some files, although already tagged (tags can be viewed in MediaInfo or exiftool), other tag editing software has to rewrite the entire file when it first needs to save edited tags, but thereafter can just edit the tags in-place, almost instantly.

So my question is still, why?

2MR2PostMay 8, 2020, 07:27
Avatar photo
Administrator
Posts: 2084
Registered:
August 23, 2012, 19:27
Hot topicRe: Save modified tags to video file

The algorithm is the basically same for all audio file formats. The required size of the new tag area is established before a single byte is written to the file. If the new data will fit at the old location (with all adjacent free space accumulated) the file is updated by writing the new data in place. If it doesn't fit the entire file must be rewritten.

This is slightly more complicated in MPEG-4 files as the format uses absolute data pointers. Whenever a file is rewritten, small chunks of the file must must be rewritten to correct the pointers (which are outside the tag area). If this is not done, the file will not play. Luckily these items can be rewritten in place. Regardless, the writing of these changed areas is not time consuming. Some writers of the files structure the file so that the metadata is more or less at the end of the file. This is unfortunately rarer in MPEG-4 files. In DSF files the developers were really smart ... the metadata can only go at the end of the file.

The fact that another tagger has already tagged the file is meaningless. In fact, it is meaningless to say that Yate has already tagged the file. It all depends on sizes and free space. Yate allows you to configure how much free space you want to insert when a file is rewritten. This is set by default to 2k which is sufficient to handle most minor tagging sessions. This will not handle the insertion of a new large artwork item.

Example:
- The in file metadata occupies 100k and you have 20k of adjacent free space.
- You replace a current 20k image with a new image which requires 100k.
- The metadata now requires 180k but you only have 120k available
- The file has to be completely rewritten

UKenGBPostMay 9, 2020, 04:32
Advanced
Posts: 57
Registered:
April 30, 2020, 09:36
Hot topicRe: Save modified tags to video file

Ah ok, got it. So if the available space for the metadata is insufficient, the entire file needs to be rewritten. But then with more space available, later changes may (probably will) not require it to be rewritten again.

As you say, this is independent of who or what has previously written the tags. It's just down to what space is available and what needs to be written.

Presumably tagging at the end of the file can solve this as more space can be created without a complete re-write. But I believe metadata at the beginning of the file is preferred for video as when streaming, the recipient gets the metadata first, which can help with displaying that data.

All clear now, thanks.

UKenGBPostJune 9, 2020, 14:11
Advanced
Posts: 57
Registered:
April 30, 2020, 09:36
Hot topicRe: Save modified tags to video file

Further use of Yate with video files reveals a big difference with what Yate considers enough space to write the metadata, compared to other tagging software.

As mentioned before, I use Subler for some things and virtually EVERY video file for which I use Subler to edit a tag, it writes the changes almost instantly - so able to save the changes without having to expand the metadata space.

But virtually EVERY video file (from same source) for which I try to use Yate to do roughly the same thing, requires the entire file to be re-written. Apparently because Yate thinks it needs to expand the metadata space.

I understand the explanation in the post above, but for some reason the result is that Yate seems to always need more metadata space to write the changes than other apps like Subler. Why is this? Can its calculation of required space be 'tuned' so that Yate doesn't need to create as much space as it (apparently erroneously) now thinks that it does?

2MR2PostJune 9, 2020, 16:54
Avatar photo
Administrator
Posts: 2084
Registered:
August 23, 2012, 19:27
Hot topicRe: Save modified tags to video file

There is only one way to calculate the available space. The only possible reason is that the amount of free space allocated after a full write can differ between applications. Perhaps this other application inserts a larger amount of free space.

By default Yate doesn't reduce free space unless explicitly told to do so. However, when there is not enough free space Yate allocates a pad when doing the total rewrite. Yate's default pad is 2000 because most people use the application for audio files and want smaller amounts of free space in the files.

SO if the first time you tag the file in Yate and it has to be rewritten Yate will allocate the new tag information plus 2k. If the next time you tag you need more than the old size plus 2k, the file will be rewritten again.

You can change the amount of padding in Preferences-Audio-Common. Make sure that 'Remove free Space' is not set and change the padding to a larger value. Try 20k as opposed to 2k.

The Algorithm is that Yate determines the size of the old tag information and coalesces all adjacent free space. If the new tag does not fit in that amount the file must be rewritten. There is no other way to handle the issue. It fits or it doesn't.

You can always do a raw dump of the files before tagging in Yate and after. In the same Preferences-Audio-Common panel enable 'Verbose log raw data'. Set the limit to 500. To take a raw dump, select one or more files and do a View>Raw Data.

You can save the displayed information via Command-S. If you want to send us before and after files send them to support@2manyrobots.com.

UKenGBPostJune 20, 2020, 11:26
Advanced
Posts: 57
Registered:
April 30, 2020, 09:36
Hot topicRe: Save modified tags to video file

My observation of Yate is that it re-writes the entire file (apparently to increase metadata space) when other apps (e.g. Subler) do not and are able to simply add the new metadata without having the re-write the entire file.

I recently had a whole series of MP4 files, with the 'Show' tag set as 'ShowName series x' and I wanted to change that to just 'ShowName', no other changes so reducing the required tag space. Yate promptly re-wrote every one of the 20 or so files which took rather a long time as each one was about 2 GB. I know Subler would save each of those files instantly, but it has no ability to operate on more than a single file, hence why I want to use Yate as it's tagging control is excellent, but each time I make such a simple change, I have to leave it for an hour or so to re-write all the files, which eliminates any advantage from using it to handle multiple file operations.

As far as I can determine, with files like these (from same source) Yate ALWAYS has to re-write them the first time. Any subsequent change does not require this. So what it does that first time can cope with a second edit, presumably as it now sees enough space to perform the edit. But since Subler NEVER has to re-write these files, even when adding to the metadata, I can only conclude that Yate is somehow getting its sums wrong.

I'll do a direct comparison on the same file…

2MR2PostJune 20, 2020, 12:02
Avatar photo
Administrator
Posts: 2084
Registered:
August 23, 2012, 19:27
Hot topicRe: Save modified tags to video file

The only possibility I can think of is that the files do not have the udta-meta-ilst sequence of atoms. If any of these are missing Yate always rewrites the file. This would only happen once. When writing in place Yate is essentially rewriting the ilst atom, adjusting the free space, etc.

I can look at this...but before I go down the rabbit hole please have a look at one of your files before tagging it. Do a View>Raw Data. Once the Log Viewer opens do a search for udta. Then look at the subtree to see if meta is missing.

If you wish you can save the file and send it to us at support@2manyrobots.com.

UKenGBPostJune 20, 2020, 12:13
Advanced
Posts: 57
Registered:
April 30, 2020, 09:36
Hot topicRe: Save modified tags to video file

Yup. I duplicated one of the MP4 files that needed the Series number removed from the 'Show Name' tag. Subler saves it instantly. Yate takes about a minute.

Although 1 minute doesn't seem long, when there's 30 or so files to save, it's definitely time for a coffee and frustrating as Subler takes no time at all to do the same job. Yate is unnecessarily rewriting these files. Whatever its reason, it doesn't need to be doing it.

UKenGBPostJune 20, 2020, 12:15
Advanced
Posts: 57
Registered:
April 30, 2020, 09:36
Hot topicRe: Save modified tags to video file

It's saving a load of files right now. I'll have another look when it's finished. It might be some time. 🙂

Pages: 1 2
Mingle Forum by Cartpauj | Version: 1.1.0beta | Page loaded in: 0.03 seconds.