TuneSpan Doesn't Rename Like iTunes Does

AkuKnives shared this question 7 years ago
Answered

**This is gonna be a tad bit nitpicky, and I apologize in advanced.


So I've noticed that while TuneSpan does indeed rename my files when spanning them, it doesn't follow the exact renaming structure that iTunes follows. I'm particularly referring to media resolution.


iTunes will name the file:


01 The Ties That Bind (1080p).m4v


- or -


01 The Ties That Bind (720p).m4v


- or -


01 The Ties That Bind.m4v (but only if it's sub 720p content)


but TuneSpan will just rename it:


01 The Ties That Bind.m4v


regardless of the resolution of the content.


Is there any way to have TuneSpan quickly scan the resolution tag of the content and include it at the end of the filename?

Replies (22)

photo
1

TuneSpan should be retaining the video quality tag in the file names. So, this is basically a bug, not just an oversight. I did put in extra effort to have TuneSpan keep those tags with the file names, but it was kinda tricky since the data I get from iTunes doesn't actually specify the video quality other than this tag in the original file name.


I'm outta the house now, but I'll look into this part of the code when I get back and may get in touch for your help testing the issue.

photo
1

My code is looking for a "HD)" suffix on the file name to preserve the video quality tag.


I had to rely on analyzing the original filename since this video quality data isn't actually available from the XML iTunes Library.


With all of my HD movies, they are appended with the tags "(1080p HD)" or " (HD)" etc. The "HD)" suffix was always there, so I relied on that to get the quality tag.


But, you're saying yours are simply "(1080p)" or "(720p)" which clearly isn't getting caught by my code. Is this how all of your files were named by iTunes? How long ago were they added to your iTunes Library? Maybe the standard has changed over time?

photo
1

Sorry, I forgot to add the HD suffix to the filenames that I listed. You are correct in that nothing has changed in that regard.


I guess the issue is the overall workflow. The way I have my library organized is as follows:


The iTunes ITL and XML files, along with all Music and Voice Memos are contained within the iTunes Media folder that is on my local drive. It's an SSD, so space is limited, and I want to always have my music on the local drive (it makes iTunes Match a lot faster, Genius updates a lot faster, etc).


I can have iTunes automatically consolidate new music files without having to use TuneSpan (and without having to manually consolidate my library) by simply dragging new music that I want in my library, into the "Automatically Add to iTunes" folder. iTunes will rename them and place them in the appropriate place in the iTunes Media folder locally. All is well


As for Movies and TV shows, they are both located in my Entertainment folder on an external drive. Combined, these folders are nearly 2TB (so you can imagine why I can’t keep them on my SSD). After I finish ripping and converting the Blu-Ray into an M4V file, I add the meta-data to the file using an app called Subler.


It’s quite an incredible free app that you should surely look into if you haven’t heard of it.


This app is where I add the resolution tag. iTunes would normally read this tag and rename the file by Episode/Movie Name (HD Resolution *if applicable). After ripping, converting, and meta-data-ing the files they are ready to go for iTunes, but they usually still have a generic file name like “Ironman2_disk_1.m4v”.


So, assuming I am correctly understanding how TuneSpan works, this issue is that if TuneSpan is looking to the file name itself for this "HD)" suffix, then it becomes useless for filenames that aren’t already named properly when newly imported into iTunes and when "Copy to iTunes Media Folder" is unchecked in preferences.


My goal is to be able to drag any Movie or TV show into iTunes, from any random location on my external drive, and then use TuneSpan to rename the file exactly how iTunes would and place the file into the appropriate location in my Entertainment folder.


The resolution data tag is stored in the header area of the individual file. If TuneSpan is looking to the filename itself, that won’t be ideal for many scenarios. If you want to rely on TuneSpan reading the iTunes XML, a better solution would be to go off the “Video Width” string for the specific file’s entry, as that always has the appropriate corresponding pixel count for the resolution (1920, 1280, etc). Don’t go by “Video Height” as many encoders will edit out the black bars on video, leaving you with various Video Heights, despite a video being 1080p.


PHEW! Sorry that was so long, but I wanted to be able to clearly paint the picture of what I’m attempting. It sounds a lot more complicated than it actually is. If only iTunes let your reference 2 different media folders in separate locations (with corresponding Media Types going to each location!).


Man, I hope this is clear, haha!

photo
1

That was totally clear. Thanks for the detailed info.


I understand what you're going for, and it makes a lot of sense to want to be able to use TuneSpan that way. But, that's not a use that I really considered since my data usually starts in the iTunes Media folder.


I'll look into the Video Width tag to see if I can use it. I would much rather have reliable raw data rather than depending on the filename being correct. When I wrote it originally, I think I remember that there was inconsistent info from the Video Width, but that may have just been the heights, hopefully I can depend on the widths. I'll take another look and get back to you.

photo
1

At first glance it looks like the Video Widths do vary a bit for the different possible resolutions. I'll have to figure out how iTunes makes the decision and try to replicate it.


It looks like iTunes appends filenames with either "(1080p HD)" or just "(HD)"


Is that how you see it or are there other variations?

photo
1

Yeah, those appendages are what iTunes uses. (1080HD), (HD) being 720p, and no appendage represents Standard Def video of varying sizes.


Do you not have a way to scan for the actual 1080p or 720p tag on the individual file? The reason I ask is that iTunes itself doesn't rely on the height or width of the video either (I assume the iTunes engineers also didn't want to rely on the iffyness of varying heights and widths). iTunes solely relies on that meta-data tag. Because of this, I can add a 1080p file to iTunes, but unless it has this tag, iTunes will consider it a Standard Def file.


Subler is the only app I've encountered that can actually edit this tag, as you can't edit it in iTunes.

photo
1

I would just need to add a whole bunch of extra code and libraries to be able to consistently read the varying file formats and get the appropriate info. It's just more overhead than I think it's worth to grab one little tag when I can get everything else from the XML.


From taking a close look both the "Video Width" and "Video Height" tags can be pretty inconsistent. But, it looks like iTunes will give things a "(1080p HD)" tag if the width is greater than or equal 1440, and an "(HD)" tag if the width is greater than or equal to 640. There are some cases that are marked as "(1080p HD)" that are pretty surprising, but from all I've looked at so far, I think that logic will (mostly) match how iTunes does it.

photo
1

The other tough part is that iTunes doesn't always append those tags unless multiple versions of the videos exist. From the XML alone, there is no way for TuneSpan to know whether multiple version exist. So, the basic code I described above would be overzealous with appending filenames with the video quality... which may not really be too bad of a thing to do.

photo
1

I think things are getting a little bit confused.


iTunes itself does not, in any way, analyze the actual dimensions of the file in order to decide what appendage to add to the filename.


It solely checks the metadata of the file, and will append the filename based on which of these 3 options is checked within the metadata of the file itself.


Which is why you may sometimes have all kinds of weird labels on your filenames.


It's kinda good, kind bad. Good in that you have control over the label of a file if the dimensions are exactly standard "1900x1060 can still be labeled 1080p". Bad in that I can tag a bunch of 320x240 videos as 1080p and iTunes would rename them all 1080p.

photo
1

Yep, you're totally right.


That tag appears to be "No" even if it is actually 720p or 1080p if it's the only version in iTunes. But, if there's another version, then iTunes will tag it appropriately based on "magic".


That's the tag I should be using. But I'm not sure how much code and memory overhead it would take to get that tag out of each video file. I'll look into it.

photo
1

It looks like Subler uses a Framework called "MP42Foundation" (https://bitbucket.org/galad87/mp42fou...) to get the metadata from the files. That framework is made by the same developer as Subler, which is pretty awesome that he isolated that part and released it open source.


BUT, that framework is 30MB! All of TuneSpan is currently around 7MB. So regardless of code complexity and RAM overhead, I'm pretty hesitant to add such a beast of a framework just to get one tag...

photo
1

We've stumbled upon quite a little mystery huh?


I just modified a 480p file to give it a 1080p tag and am looking at the XML file now. It seems that changing the tag to 1080p does in fact change the file's XML HD string to "True", but nowhere in the entry does it denote 1080p over 720p. So where the hell is iTunes storing this information?


photo
1

Yea, that HD tag isn't very helpful in this case since it doesn't differentiate between 1080p and below.


This XML file is full of just what Apple thinks is useful for 3rd party apps. iTunes doesn't read it, it only writes to that file. iTunes' real database is the unreadable, uneditable binary "iTunes Library.itl" file (but sometimes it has no extension).

photo
1

Going through the developer of Subler's open source files, I think I found the formula he uses. When Subler scans the web for metadata for a file, it will also scan the dimensions of the video file and will automatically set one of the 3 tags. After this process, you can change it of course if you know it's incorrect. Tell me if this code makes sense to you, and if it would be the solution to actually using the XML of iTunes.


int isHdVideo(uint64_t width, uint64_t height)


{


if ((width > 1280) || (height > 720))


return 2;


else if (((width >= 960) && (height >= 720)) || width >= 1280)


return 1;


return 0;


}

photo
1

PS. I also see cases where iTunes marks that HD tag as true but doesn't append anything in the filename.

photo
1

Yea, that code looks totally reasonable. But, the problem is still that using that alone is too overzealous. TuneSpan would append filenames in tons of cases where iTunes wouldn't append anything since there's only one version of the video.

photo
1

I don't quite understand what you mean by that. iTunes will always append the file name if that tag is present in the metadata, doesn't matter if there is only 1 version of the file or not.


Literally every 1080p file I have in iTunes has this added to its filename (which is nearly all of them), because I added these tags via Subler as I was importing them.

photo
1

Are you talking about the HD tag in the file metadata or the HD tag in the XML file? Because they do not appear to aways be the same. I saw cases that the XML had HD as true but nothing in the filename.


But if you were talking about that code you posted, that just checks the videos width and height in a naive way.

photo
1

Personally I really don't think it's that bad if I just do a naive check on the Video Width and Height and just append "(HD)" or "(1080p HD)" in cases where iTunes wouldn't. It will at least be reliable and consistent.

photo
1

Sorry, the verbiage is all a bit weird to correctly discuss on here. Yeah, I was talking about the HD tag in the metadata. I just discovered the discrepancy between the HD metadata tag in the file and the HD string in the XML.


They are actually referring to separate things.


After I changed the HD tag in the file from earlier back to "No" I noticed that while the filename reverted back to not having the (1080p HD) appendage added to it, something else didn't change. The little "HD" icon next to the title of the video inside iTunes, that little bastard was still there. In concurrence, the XML file still had the HD labeled True.


SOOO it turns out the the HD String inside the XML is designated for adding that little HD icon next to the episode title or movie name, not the actual file name. I guess the renaming of the file is solely on the responsibility of that metadata tag.


So I'd say you should totally go for the naive check of the height and width based of that code. If it's easy to implement, then hey, that's better than nothing.

photo
1

If you'd like to test the (overzealous and naive) fix, please email me directly with http://contact.tunespan.com or one of the Contact Developer links in the app.

photo
1

TuneSpan 1.2.1 which incorporates these changes for improved HD file tagging, along with adding other nice new features and improvements is now available on the Mac App Store :-)


http://mas.tunespan.com

Leave a Comment
 
Attach a file