HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: Otto42 on 2004-12-05 00:39:07

Title: iTunes Encode - New version
Post by: Otto42 on 2004-12-05 00:39:07
New version is available here:
http://otto.homedns.org:8888/iTunes/iTunesEncode46.zip (http://otto.homedns.org:8888/iTunes/iTunesEncode46.zip)

Basically the only change is to fix some problems encountered when the encode is happening. See, the iTunes interface comes up and if you click around in it a bit while the encode is going on, it could send a false signal to iTunesEncode that the encode was finished. iTunes 4.6 added some functionality to the COM interface that would allow me to avoid this. What with one thing and another, I never got around to noticing until iTunes 4.7 came out.

So this version should display a progress report in a percentage form as well as not quit prematurely. I think. I haven't done a lot of testing here.

I also added a bunch of error checking. Anyway, give it a try with EAC or clienc and let me know how it works. It might not work at all, in which case let me know that too.

Edit: One known issue: If you open a modal dialog in iTunes like the Options or Preferences screen while it's encoding, iTunesEncode might still quit prematurely. I'm checking that out. There is a fix but I'm not sure it's the right way to do it yet. My suggestion is to not screw around with iTunes while it's encoding.
Title: iTunes Encode - New version
Post by: G-Force on 2004-12-05 14:26:08
Thanks Otto. I've been using the previous version for awhile and love it. Looking forward to trying the new version out!
Title: iTunes Encode - New version
Post by: ezra2323 on 2004-12-05 14:42:08
Otto, what do you mean error correction? I understand this concept when ripping a WAV but encoding? You think there may be errors with the encode as well? What kinds? Do these occur when just using iTunes as well?

Also, I replaced AACencode.js with iTunes.exe in both the EAC folder location and the command-line and now it does not seem to work. (so I put AACencode.js back) Everything else remained the same as before. What am I doing incorectly? Trying to follow the read-me file.

Thanks for your work on this.
Title: iTunes Encode - New version
Post by: Otto42 on 2004-12-05 18:18:19
ezra: iTunes.exe or iTunesEncode.exe?

And I mean error checking, not error correction. iTunes can stop for all sorts of reasons, so iTunesEncode is checking error responses from the calls to iTunes and will spit out more useful error messages now. Also it'll return an error code and if EAC checks that error code, it'll not delete the temporary WAV, because iTunesEncode won't have been able to finish encoding it.

To set it up in EAC, go to the Compression Options:
-Use External Program for Compression is on
-User Defined Encoder
-Extension is .M4A
-Program is c:\full\path\to\iTunesEncode.exe
-Additional command line options are similar to this:
Code: [Select]
-e "AAC Encoder" -a "%a" -l "%g" -t "%t" -g "%m" -y %y -n %n -i %s -o %d -d

-Delete WAV after Compression is ON
-Add ID3 tag is OFF
-Check for external programs return code is ON

Current News:
-Yes, the percentage indicator doesn't work. Not sure why yet. (Edit: this is now fixed, redownload it)
-I'm also working on adding Artwork capabilities at the moment.
(Edit2: Artwork is now an option as well. Add -r "c:\full\path\to\artwork.jpg" to the command line to add artwork to the file. JPG or PNG are allowed by iTunes.)
Title: iTunes Encode - New version
Post by: jMc777 on 2004-12-05 19:45:20
Good work Otto - much appreciated! 
Title: iTunes Encode - New version
Post by: ezra2323 on 2004-12-05 23:06:24
Yeah, great stuff!!!

Quote
Artwork is now an option as well. Add -r "c:\full\path\to\artwork.jpg" to the command line to add artwork to the file


Does this go at the end of the additional command line? After the -d???
Title: iTunes Encode - New version
Post by: matth6546 on 2004-12-06 01:24:27
sounds awesome! one question though - since EAC is unable to get tags from freedb for a lot of people, is it possible to have itunesencode import the tags from itunes?
Title: iTunes Encode - New version
Post by: Otto42 on 2004-12-06 03:54:52
Quote
Quote
Artwork is now an option as well. Add -r "c:\full\path\to\artwork.jpg" to the command line to add artwork to the file

Does this go at the end of the additional command line? After the -d???
[a href="index.php?act=findpost&pid=257940"][{POST_SNAPBACK}][/a]

Put it anywhere you like. The options are not order sensitive.

Quote
sounds awesome! one question though - since EAC is unable to get tags from freedb for a lot of people, is it possible to have itunesencode import the tags from itunes?
[a href="index.php?act=findpost&pid=257960"][{POST_SNAPBACK}][/a]

iTunes gets its track info from Gracenote, aka CDDB. If CDDB has it, chances are good that FreeDB has it.

But a more direct answer is no, you can't make iTunes download track info. iTunes is only capable of getting track info from Gracenote if iTunes itself rips the CD.
Title: iTunes Encode - New version
Post by: M on 2004-12-06 05:54:34
Two (hopefully) quick questions:

  1) Could you add a switch for the "Grouping" field? I realize one could use the "Comment" field to store grouping data, but iTunes would not recognize that... plus I occasionally use "Comments" for, well, comments.

  2) Is there a way (yet) to directly translate FLAC comments to iTunes tags, during the encoding process? (And yes, I am adding user-defined "grouping" tags in my FLACs, as GROUPING=. Ultimately, I would like a way to go straight from FLAC to M4A, appropriately mapping the existing FLAC comments to the equivalent M4A tags.)

    - M.
Title: iTunes Encode - New version
Post by: Otto42 on 2004-12-06 15:36:13
Quote
Two (hopefully) quick questions:
  1) Could you add a switch for the "Grouping" field? I realize one could use the "Comment" field to store grouping data, but iTunes would not recognize that... plus I occasionally use "Comments" for, well, comments.
  2) Is there a way (yet) to directly translate FLAC comments to iTunes tags, during the encoding process? (And yes, I am adding user-defined "grouping" tags in my FLACs, as GROUPING=. Ultimately, I would like a way to go straight from FLAC to M4A, appropriately mapping the existing FLAC comments to the equivalent M4A tags.)
[a href="index.php?act=findpost&pid=257980"][{POST_SNAPBACK}][/a]

I left off Grouping specifically because it's not stored in the file itself, I think. I'll do some testing.

As for the FLAC comments, I imagine you can do anything you like there if you use foobar and clienc to call the program. But it has to have an intermediate WAV stage, since iTunes can't read FLAC files.
Title: iTunes Encode - New version
Post by: reardon on 2004-12-06 17:23:40
Quote
New version is available here:
http://otto.homedns.org:8888/iTunes/iTunesEncode46.zip (http://otto.homedns.org:8888/iTunes/iTunesEncode46.zip)
I also added a bunch of error checking. Anyway, give it a try with EAC or clienc and let me know how it works. It might not work at all, in which case let me know that too.

[a href="index.php?act=findpost&pid=257841"][{POST_SNAPBACK}][/a]


(posted in fb2k forum)

Add images to files? Browsing the interfaces it looks like this can be done. I would like to use iTunesEncode as BOTH an encoder and as an external tagger (since foobar currently trashes any binary tags, like cover art (COVR) or the compilation (CPIL) tags. I think those are the field names anyway.

+Reardon
Title: iTunes Encode - New version
Post by: Otto42 on 2004-12-06 17:46:09
Quote
Add images to files? Browsing the interfaces it looks like this can be done. I would like to use iTunesEncode as BOTH an encoder and as an external tagger (since foobar currently trashes any binary tags, like cover art (COVR) or the compilation (CPIL) tags. I think those are the field names anyway.[a href="index.php?act=findpost&pid=258087"][{POST_SNAPBACK}][/a]

I just added the album art ability yesterday. Check out the new -r option.

But making it able to function as a tagger without also doing the encoding process poses a number of challenges. iTunes can only manipulate files that are in its "library". So you'd need to add the file to the library, do some stuff, then maybe remove it again. If the file was already in the library, you wouldn't be able to add it again, and there's some other hurdles there.

Seems to me that it'd be simpler to modify existing MP4 tagger code to add an "iTunes compatibility mode" of sorts. iTunes is pickier than it needs to be about MP4 tags, but a simple reordering of tags in the file should work, methinks.
Title: iTunes Encode - New version
Post by: Iconoclast_a on 2004-12-06 23:43:00
Great to see this handy app continue it's improvement. =)

What does the 46 in iTunesEncode46.zip stand for?

Perhaps you could implement some kind of versioning, or at least the date of compilation.

And keep up the great work!
Title: iTunes Encode - New version
Post by: Otto42 on 2004-12-07 16:30:45
Quote
What does the 46 in iTunesEncode46.zip stand for?
[a href="index.php?act=findpost&pid=258165"][{POST_SNAPBACK}][/a]

iTunes 4.6 or higher is now required, and I wanted to give the zip a different name since it was just a test version sort of thing. I don't think it's necessary to actually use a version number system yet. The changes were pretty minor and there's relatively few improvements that can be added to it at this point.
Title: iTunes Encode - New version
Post by: reardon on 2004-12-07 18:46:28
Quote
But making it able to function as a tagger without also doing the encoding process poses a number of challenges. iTunes can only manipulate files that are in its "library". So you'd need to add the file to the library, do some stuff, then maybe remove it again. If the file was already in the library, you wouldn't be able to add it again, and there's some other hurdles there.
[a href="index.php?act=findpost&pid=258091"][{POST_SNAPBACK}][/a]


Well the interfaces definitely support library manipulation. But I under it is a bit of work and not the focus of your utility.

Do you know any CLI MP4/AAC taggers?  I haven't found _any_.

+Reardon
Title: iTunes Encode - New version
Post by: MagicRat on 2004-12-08 00:14:57
I just wanted to say "Thank You" as well.  This is a really nice little app.  Thanks for taking the time, Otto42.
Title: iTunes Encode - New version
Post by: Otto42 on 2004-12-08 06:18:46
Quote
Do you know any CLI MP4/AAC taggers?  I haven't found _any_.[{POST_SNAPBACK}][/a] (http://index.php?act=findpost&pid=258346")

Quick search in the AAC forum found this: [a href="http://users.rcn.com/rpritz/tgutf.zip]http://users.rcn.com/rpritz/tgutf.zip[/url]
Title: iTunes Encode - New version
Post by: Domain on 2005-02-15 18:09:28
Otto,

Just out of curiosity, how did you end up handling COM being disabled by user interface interaction? I spent a few days without luck trying to resolve that problem, but I never found a nice solution since the event handler for COM being disabled would block the interface thread...

The final soultion I came up with was using a catch / throw system that would attempt to retry whatever command was interrupted a certain number of times, but I never found this to be very elegant.

Thanks,

Domain
Title: iTunes Encode - New version
Post by: Otto42 on 2005-02-15 18:56:01
Quote
Just out of curiosity, how did you end up handling COM being disabled by user interface interaction? I spent a few days without luck trying to resolve that problem, but I never found a nice solution since the event handler for COM being disabled would block the interface thread...

The final soultion I came up with was using a catch / throw system that would attempt to retry whatever command was interrupted a certain number of times, but I never found this to be very elegant.
[{POST_SNAPBACK}][/a] (http://index.php?act=findpost&pid=273842")

Simple answer: I didn't.

Longer answer: If you use iTunesEncode46 and screw around enough with dialogs and such while it's encoding, you can, rarely, cause iTunesEncode to quit early. As a solution, I stopped screwing around with the dialogs in iTunes while it's encoding.

I also found that the newer ConvertFile2 which gives the more useful status information about the conversion in progress doesn't seem to stop working nearly as often as the older ConvertFile did. Simply messing around with playlists and such won't stop it from working, and modal dialog boxes don't seem to impact it either, most of the time. So it's only a sometimes event, sort of thing. But basically I ignored the problem entirely unless I got enough reports to make me do something about it. I tried to solve other, more common, problems instead.

iTunesEncode46 is pretty stable now. You can still cause it to break if you try hard enough though. [a href="http://otto.homedns.org:8888/iTunes/iTunesEncode46.zip]http://otto.homedns.org:8888/iTunes/iTunesEncode46.zip[/url]


Edit: I did recently discover that "Grouping" info is indeed added to the tag of MP3 files. Don't recall how, exactly, but it's in there. So I'll be adding grouping support to iTunesEncode as soon as I get a chance.

Edit2: Done, grouping is now accessible in iTunesEncode with the -u option. (g, r, and o were already taken). Also cleaned up the help screen that prints when you run iTunesEncode without any parameters.
Title: iTunes Encode - New version
Post by: VCSkier on 2005-02-25 04:40:55
i can't get your downloads to work...  is it my comp?  im running w/ firefox, and it opens a new blank window, and then after a few seconds, i get a error that says "the operation timed out when attempting to contact otto.homedns.org."  is your link broken, or is it me?

edit: typo...  lol, one letter can make a big difference...
Title: iTunes Encode - New version
Post by: Mono on 2005-02-25 05:49:43
Link works OK for me, using wget and firefox.
Title: iTunes Encode - New version
Post by: spies on 2005-03-04 19:03:45
OK, I followed Otto42's suggestion for setting up EAC with the wonderful iTunesEncode as follows:
Quote
To set it up in EAC, go to the Compression Options:
-Use External Program for Compression is on
-User Defined Encoder
-Extension is .M4A
-Program is c:\full\path\to\iTunesEncode.exe
-Additional command line options are similar to this:
Code: [Select]
-e "AAC Encoder" -a "%a" -l "%g" -t "%t" -g "%m" -y %y -n %n -i %s -o %d -d

-Delete WAV after Compression is ON
-Add ID3 tag is OFF
-Check for external programs return code is ON

This works great but I would like to leave the AAC file in iTunes. So I removed the -o and -d options from the EAC Config string to look like this:
Code: [Select]
-e "AAC Encoder" -a "%a" -l "%g" -t "%t" -g "%m" -y %y -n %n -i %s

This results in the AAC file staying in iTunes like I want  but EAC no longer deletes the WAV file  Why did EAC stop deleting the WAV and what can I do to change it?  Am I missing something?
Title: iTunes Encode - New version
Post by: Otto42 on 2005-03-04 19:16:52
Quote
This works great but I would like to leave the AAC file in iTunes. So I removed the -o and -d options from the EAC Config string to look like this:
Code: [Select]
-e "AAC Encoder" -a "%a" -l "%g" -t "%t" -g "%m" -y %y -n %n -i %s

This results in the AAC file staying in iTunes like I want  but EAC no longer deletes the WAV file  Why did EAC stop deleting the WAV and what can I do to change it?  Am I missing something?
[a href="index.php?act=findpost&pid=279260"][{POST_SNAPBACK}][/a]

EAC is passing the place where it wants the output file to be using the %d variable. When you leave that out, and thus the file isn't copied there, EAC assumes something went wrong with the encode, and doesn't delete the temporary WAV file.

What I do is to leave the -o %d option in there, so that EAC is satisfied, and then every so often I remove the excess M4A files. It's not a great solution, I admit.
Title: iTunes Encode - New version
Post by: spies on 2005-03-04 19:30:00
Quote
EAC is passing the place where it wants the output file to be using the %d variable. When you leave that out, and thus the file isn't copied there, EAC assumes something went wrong with the encode, and doesn't delete the temporary WAV file.

What I do is to leave the -o %d option in there, so that EAC is satisfied, and then every so often I remove the excess M4A files. It's not a great solution, I admit.
[a href="index.php?act=findpost&pid=279264"][{POST_SNAPBACK}][/a]

Thanks Otto42, I think I will go back to using the original EAC config string and just add the files back to iTunes later, that way I do not have to worry about having duplicates
Title: iTunes Encode - New version
Post by: Otto42 on 2005-03-04 23:09:21
Nah, do what I do. Just leave out the -d to leave the resulting files in iTunes. When you rip a disk, always rip it to the same directory in EAC (some temp directory somewhere, like c:\temp). Every so often, just delete the contents of the temp directory. It works great.

When iTunes encodes, it puts the resulting file in iTunes library and manages the filename and such all by itself. Works pretty well, overall. So I let it do that (since I have an iPod to sync with anyway) and then just delete the dupes from the ripping+encoding process.
Title: iTunes Encode - New version
Post by: spies on 2005-03-05 18:31:34
I figured out another way to do it  In EAC use the file naming scheme "%D\%C\%N %T" and point EAC to the same directory that iTunes is using such as "C:\iTunes Music\" In iTunes turn on "Keep iTunes Music folder organized" Then use the suggested EAC command line option but just leave out the -d. I am not sure why this works  but this will result in EAC deleting the original WAV file and only one file from iTunes on the drive. Check it out and let me know what you think. BTW I'm doing all of this in Virtual PC on a Mac and it works great, albeit a little slow, but worth it 
Title: iTunes Encode - New version
Post by: Otto42 on 2005-03-06 04:28:59
Quote
I am not sure why this works
[a href="index.php?act=findpost&pid=279537"][{POST_SNAPBACK}][/a]

It works because you're telling iTunesEncode to not move the file to any destination and EAC is finding the file in the location it expects to move/rename it to eventually (EAC specifies this using the %o parameter, I think). So EAC looks for a file in the %d location, and failing that, it looks in the %o location. Since your naming scheme is the same as what iTunes is using by default, EAC is satisfied and deletes the WAV file.

This will work as long as you don't feed iTunesEncode a disc number parameter (which is not in those recommended settings anyway).
Title: iTunes Encode - New version
Post by: Supernaut on 2005-03-13 18:36:26
Hey

I was wondering if it was possible to transfer the track rating (0-5) to iTunes on encoding. I can't see it in iTunesEncode's command-line options.. If it's possible, could you please update your tool to allow for that?

Thanks
Title: iTunes Encode - New version
Post by: webspiffy on 2005-04-11 02:50:09
Is iTunes 4.7.1 not fully compatible with iTunesEncode? I can transcode to AAC just fine but when I try to do lossless (ALAC) I get an error message in foobar that encoding failed. This didn't used to happen to me and all I did was upgrade my version of iTunes.

Update: Never mind, I'm a dork and forgot that I changed the location of iTunesEncode.exe. It works fine with 4.7.1!!
Title: iTunes Encode - New version
Post by: optimus on 2005-11-04 11:57:39
Quote
New version is available here:
http://otto.homedns.org:8888/iTunes/iTunesEncode46.zip (http://otto.homedns.org:8888/iTunes/iTunesEncode46.zip)

Basically the only change is to fix some problems encountered when the encode is happening. See, the iTunes interface comes up and if you click around in it a bit while the encode is going on, it could send a false signal to iTunesEncode that the encode was finished. iTunes 4.6 added some functionality to the COM interface that would allow me to avoid this. What with one thing and another, I never got around to noticing until iTunes 4.7 came out.

Hi Otto, I've integrated your iTunesEncode in my MediaCoder (http://www.rarewares.org/mediacoder/). What I would like to do now is to do a source level integration. Could you provide me with the source code of iTunesEncode?
Title: iTunes Encode - New version
Post by: Otto42 on 2005-11-04 19:05:10
The source code was lost in a hard drive incident many moons ago. This is why I've not updated it with new features, because I don't feel like rewriting the thing. Anyway, it includes support for most everything that can be included.

It was not particularly complex code though, anybody could duplicate it with only a small amount of effort. Take a look through the "iTunes COM SDK" (google for it) and all the info you need is right there.

The vast majority of the source code was doing the command line parsing. The iTunes code only comprised maybe 20% of the thing.

However, I can tell you what you need to do to duplicate it. First, convert the file to WAV or some other filetype iTunes can read. And yes, it needs to be a file, not a datastream. Next, set the iTunes encoder in the iTunes COM object. This means reading the encoder list, choosing one, and setting it. Then you call the ConvertFile2 function in the iTunes COM object to convert the file. The ConvertFile2 function gives you an object that you can poll occassionally for progress information. When it's done, you can get link to a the converted Track object. Then you can tag that track object by simply setting each of the Track's fields. Finally, you get the Track's location and then do a normal file copy to wherever you want the track to be. If you want to remove the track from iTunes, you can delete the track from the Main Library object. This doesn't delete the file itself for some reason, so you'll need to do that manually.

Pretty straightforward, really. The only caveat is that you may want to watch if iTunes disables the COM interface while it's converting. This means the user did something like opening a modal dialog in iTunes or something, and this might break your conversion status object temporarily. If you want to be tricky, find the iTunes window and hide it entirely, so they can't do that.
Title: iTunes Encode - New version
Post by: Marino13 on 2005-11-10 00:12:35
Quote
ezra: iTunes.exe or iTunesEncode.exe?

And I mean error checking, not error correction. iTunes can stop for all sorts of reasons, so iTunesEncode is checking error responses from the calls to iTunes and will spit out more useful error messages now. Also it'll return an error code and if EAC checks that error code, it'll not delete the temporary WAV, because iTunesEncode won't have been able to finish encoding it.

To set it up in EAC, go to the Compression Options:
-Use External Program for Compression is on
-User Defined Encoder
-Extension is .M4A
-Program is c:\full\path\to\iTunesEncode.exe
-Additional command line options are similar to this:
Code: [Select]
-e "AAC Encoder" -a "%a" -l "%g" -t "%t" -g "%m" -y %y -n %n -i %s -o %d -d

-Delete WAV after Compression is ON
-Add ID3 tag is OFF
-Check for external programs return code is ON

Current News:
-Yes, the percentage indicator doesn't work. Not sure why yet. (Edit: this is now fixed, redownload it)
-I'm also working on adding Artwork capabilities at the moment.
(Edit2: Artwork is now an option as well. Add -r "c:\full\path\to\artwork.jpg" to the command line to add artwork to the file. JPG or PNG are allowed by iTunes.)
[a href="index.php?act=findpost&pid=257899"][{POST_SNAPBACK}][/a]


How would i set up my command line in foobar to add artwork?  My jpeg's are called folder.jpg in each albums folder of ape files.
Title: iTunes Encode - New version
Post by: clintb on 2005-12-26 18:03:04
+1 on Marino13's request.  I have a .jpg in each folder that's named what the full album name is (single flac + cue setup).  It's also the same name as the folder it resides in (Artist ~ Date ~ Album).
Title: iTunes Encode - New version
Post by: richard123 on 2006-01-27 03:36:43
Quote
Take a look through the "iTunes COM SDK" (google for it) and all the info you need is right there. [snip]

When it's done, you can get link to a the converted Track object. Then you can tag that track object by simply setting each of the Track's fields.
[a href="index.php?act=findpost&pid=339557"][{POST_SNAPBACK}][/a]
Looking at the SDK, I can see how to set every tag field other than the title of the track.  Album, artist, genre, date are all easy.  How do you set title?
Title: iTunes Encode - New version
Post by: sehested on 2006-01-27 06:51:07
Quote
Quote
Take a look through the "iTunes COM SDK" (google for it) and all the info you need is right there. [snip]

When it's done, you can get link to a the converted Track object. Then you can tag that track object by simply setting each of the Track's fields.
[a href="index.php?act=findpost&pid=339557"][{POST_SNAPBACK}][/a]
Looking at the SDK, I can see how to set every tag field other than the title of the track.  Album, artist, genre, date are all easy.  How do you set title?
[a href="index.php?act=findpost&pid=360072"][{POST_SNAPBACK}][/a]

The title property is called Name in the SDK.
Title: iTunes Encode - New version
Post by: richard123 on 2006-01-27 12:15:59
Quote
The title property is called Name in the SDK.
[a href="index.php?act=findpost&pid=360085"][{POST_SNAPBACK}][/a]
Aha!  I was looking under IITrack (which has every other tag property), while Name is listed under IITObject

thanks
Title: iTunes Encode - New version
Post by: zzoebl on 2007-01-06 16:28:56
Hi, I had to register just to say what an excellent program you've made. I struggled to find the itunesEncode46.zip file because all the links were down. So if anyone finds this post and can't download it, get it here (http://www.hydrogenaudio.org/forums/index.php?showtopic=35242)

This is exactly what I've been looking for, thank you so much Otto. I've just tested a few tracks and it works wonderfully.

Great readme as well