Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Adding metadata to existing itunes library and multi languages

Thanks for this tool corresponding to what I was looking for since a long time. I an currently an handbrake user, but was doing it manually. I have however the following unsolved issues:
1) I have 300 movies in itunes library that I created from DVD using handbrake. Which script should I use to add retroactively the missing metadata (cover, comments...). Modifying the file name breaks the links in itune library.
2) I am french leaving in germany and working in english. Depending of the circumstances, we are watching movies in any of these language with or without subtitles. The DVD I buy can be in any of these 3 languages or a combination of them. How can I encode simultaneously in any of these 3 languages available with the subtitles.
3) the subtitle seems to be burnt in despite handbrake support a separate encoding.
Thanks again.
 
Thanks for this tool corresponding to what I was looking for since a long time. I an currently an handbrake user, but was doing it manually. I have however the following unsolved issues:
1) I have 300 movies in itunes library that I created from DVD using handbrake. Which script should I use to add retroactively the missing metadata (cover, comments...). Modifying the file name breaks the links in itune library.
2) I am french leaving in germany and working in english. Depending of the circumstances, we are watching movies in any of these language with or without subtitles. The DVD I buy can be in any of these 3 languages or a combination of them. How can I encode simultaneously in any of these 3 languages available with the subtitles.
3) the subtitle seems to be burnt in despite handbrake support a separate encoding.
Thanks again.

Im afraid I can only help you with #1.

Yes, the filename breaks it in itunes, the only way that you can do it, is to move the movies to another location, delete the links in itunes, tag and rename or whatever you do, and then add them back into itunes. If you have itunes setup to move your files around, then your gold, delete the originals once your done.
 
Thanks for this tool corresponding to what I was looking for since a long time. I an currently an handbrake user, but was doing it manually. I have however the following unsolved issues:
1) I have 300 movies in itunes library that I created from DVD using handbrake. Which script should I use to add retroactively the missing metadata (cover, comments...). Modifying the file name breaks the links in itune library.
2) I am french leaving in germany and working in english. Depending of the circumstances, we are watching movies in any of these language with or without subtitles. The DVD I buy can be in any of these 3 languages or a combination of them. How can I encode simultaneously in any of these 3 languages available with the subtitles.
3) the subtitle seems to be burnt in despite handbrake support a separate encoding.
Thanks again.

For #1 HackerJL's process is a good one. But you can add metadata in place using one of the Add Movie Tag Services, just make sure that the Rename option is unchecked in the Service. Also, make sure iTunes is NOT running when you run the service. When active, iTunes will track the file's location if it's moved. The Service moves the original file to the trash and iTunes will remain linked to that file. If iTunes is not running, the link stays the same and will find the new file if it's named the same and in the same location. After you have updated the metadata, you'll have to right-click on the file and Choose > Get Info (Command+I) to update the iTunes library with the new metadata.

#2: HB's GUI is probably better choice than trying to automate it. Batch Encode is designed to select 1 audio track; either your preferred audio language or the default audio language of the disc depending on how you set your options. For multiple languages, you could try using a custom encode setting using HB's command line options ... but it's difficult to reliably automate this since each disc will have different languages that you may or may not want to encode and they may be in a different order of preference. The process may fail if the audio tracks or subtitle tracks you set up in a custom setting are not available.

#3: It's been a while since I researched this, but I remember that there were a lot of issues with "soft-subtitles", only certain types of subtitle sources can be used as soft-subtitles. For Batch Encode, subtitle support is limited. It's primarily meant for forced-subtitles; when short segments of dialog are in a language different from the main audio language, or for foreign language films; when the viewer's language is different than the default audio language. To make this process work for both Blu-ray and DVD and work "most" of the time, I chose to burn-in the subtitles.
 
For #1 HackerJL's process is a good one. But you can add metadata in place using one of the Add Movie Tag Services, just make sure that the Rename option is unchecked in the Service. Also, make sure iTunes is NOT running when you run the service. When active, iTunes will track the file's location if it's moved. The Service moves the original file to the trash and iTunes will remain linked to that file. If iTunes is not running, the link stays the same and will find the new file if it's named the same and in the same location. After you have updated the metadata, you'll have to right-click on the file and Choose > Get Info (Command+I) to update the iTunes library with the new metadata.

#2: HB's GUI is probably better choice than trying to automate it. Batch Encode is designed to select 1 audio track; either your preferred audio language or the default audio language of the disc depending on how you set your options. For multiple languages, you could try using a custom encode setting using HB's command line options ... but it's difficult to reliably automate this since each disc will have different languages that you may or may not want to encode and they may be in a different order of preference. The process may fail if the audio tracks or subtitle tracks you set up in a custom setting are not available.

#3: It's been a while since I researched this, but I remember that there were a lot of issues with "soft-subtitles", only certain types of subtitle sources can be used as soft-subtitles. For Batch Encode, subtitle support is limited. It's primarily meant for forced-subtitles; when short segments of dialog are in a language different from the main audio language, or for foreign language films; when the viewer's language is different than the default audio language. To make this process work for both Blu-ray and DVD and work "most" of the time, I chose to burn-in the subtitles.

Oh, forgot about the option NOT to rename. My bad. In my defence, (hehe) I use the naming convention to tell me which ones HAVE been tagged properly.

----------

Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5)

At some point Spotlight no longer supported the kDMItemMusicalGenre (Musical Genre) attribute for movie files, so Hazel can't use it anymore. It's still in use for audio files. For me, this was the best way to assure a file was tagged. Unfortunately, I haven't had time to research an alternative method.

In Terminal, you can use the mdls command to see all the attributes of a file. Just type: mdls "/path/to/file.ext"

If this spotlight feature isnt available anymore, is there a way to add to the naming convention? Example. If the encode works, but cant be tagged properly, maybe add '-untagged' to the filename. Then automation like hazel could watch for that. Im sure there are a million different ways/opinions on this, but something that hazel could watch/read would be beneficial. Of course, if you had the inclination, I could test it for you.
 
mac.jedi, or anyone else. What is the best way to retrospectively add chapter markers and titles to an encoded m4v file?

When I try to run the add chapter names or add movie tags actions on an m4v encoded from an avi or mkv file it can't add them.

I guess this is because when I rip a DVD it adds the chapter markers as it encodes, but when I encode from a different format they aren't added?

Can anyone suggest a method to do this retrospectively?
 
mac.jedi, or anyone else. What is the best way to retrospectively add chapter markers and titles to an encoded m4v file?

When I try to run the add chapter names or add movie tags actions on an m4v encoded from an avi or mkv file it can't add them.

I guess this is because when I rip a DVD it adds the chapter markers as it encodes, but when I encode from a different format they aren't added?

Can anyone suggest a method to do this retrospectively?

Batch Encode will add the chapter markers automatically if they are present in the mkv file, not sure about avi but I imagine HB would handle them the same way.

To add chapters markers to an existing file, iDentify or MetaX would probably be the easiest. I'm not 100% sure, but I think they offer the option to create chapter markers as well as tagging them. The downside is that, you can't guarantee that the markers (or the names) you get from tagChimp are going to match up to the timeline in your file. It's for this reason that the workflows included with Batch Rip Actions for Automator require that chapter markers already exist in the file; thereby only adding chapter names to the existing markers and not overwriting them … possibly creating markers that are out of sync. This is also the reason why adding chapter names doesn't always work, since the number of chapters on tagChimp don't always match the number of chapters in the file.

If you don't care about the names or times, and just want markers every 5 minutes or so, you can use mp4chaps.

In Terminal type:
Code:
mp4chaps --every 300 "/path/to/file.m4v"
 
If this spotlight feature isnt available anymore, is there a way to add to the naming convention? Example. If the encode works, but cant be tagged properly, maybe add '-untagged' to the filename. Then automation like hazel could watch for that. Im sure there are a million different ways/opinions on this, but something that hazel could watch/read would be beneficial. Of course, if you had the inclination, I could test it for you.

I'd rather figure out a way for Hazel to do it rather than adding something to the action. A down and dirty way to do it would be to have Hazel match all movie files then add a "Run Shell Script" on the matched file to see if it's got a genre added:

Code:
mp4infoPath="/usr/local/bin/mp4info"
getGenre=`"$mp4infoPath" "$1" | grep "Genre"`
fileName=`basename "$1"`

#ADD THE PATH to your "Automatically Add to iTunes" Folder (if you're iTunes folder isn't in your home folder you'll have to edit the path below)
iTunesFolder="$HOME/Music/iTunes/iTunes Media/Automatically Add to iTunes/$fileName"

if [ ! -z "$getGenre" ]; then
	# Move File to your "Automatically Add to iTunes" Folder
	#mv "$1" "$iTunesFolder"
	
	# Copy File to your "Automatically Add to iTunes" Folder
	cp "$1" "$iTunesFolder"
fi

I hope this helps a bit :)
 
If this spotlight feature isnt available anymore, is there a way to add to the naming convention? Example. If the encode works, but cant be tagged properly, maybe add '-untagged' to the filename. Then automation like hazel could watch for that. Im sure there are a million different ways/opinions on this, but something that hazel could watch/read would be beneficial. Of course, if you had the inclination, I could test it for you.

The previous code I posted was to actually move the file. Another option would be to have Hazel rename the files in a separate rule. Then have another rule move only the tagged files.

Code:
mp4infoPath="/usr/local/bin/mp4info"
getGenre=`"$mp4infoPath" "$1" | grep "Genre"`
fileNameNoExtension=`basename "$1" .m4v`
fileDir=`dirname "$1"`
untaggedFileName="${fileNameNoExtension}-untagged.m4v"
taggedFileName="${fileNameNoExtension}-tagged.m4v"
if [ -z "$getGenre" ]; then
	# Rename File if no genre is found
	mv "$1" "${fileDir}/${untaggedFileName}"
else
	# Rename File if genre is found
	mv "$1" "${fileDir}/${taggedFileName}"
fi
 
Last edited:
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5)



Thanks SquirrelWorks!

I used to do that back in the day, but now Handbrake uses all the cores available, so you don't get much out of doing simultaneous encodes. But if you wanna try, the Batch Encode (Finder) Service should be able to encode simutaneously, but you'd have to start the Service manually on each source.

Not surprising, but good to know.

Thanks!
 
The previous code I posted was to actually move the file. Another option would be to have Hazel rename the files in a separate rule. Then have another rule move only the tagged files.

Code:
mp4infoPath="/usr/local/bin/mp4info"
getGenre=`"$mp4infoPath" "$1"`
fileNameNoExtension=`basename "$1" .m4v`
fileDir=`dirname "$1"`
untaggedFileName="${fileNameNoExtension}-untagged.m4v"
taggedFileName="${fileNameNoExtension}-tagged.m4v"
if [ -z "$getGenre" ]; then
	# Rename File if no genre is found
	mv "$1" "${fileDir}/${untaggedFileName}"
else
	# Rename File if genre is found
	mv "$1" "${fileDir}/${taggedFileName}"
fi

I have found an area in Hazel to check for the genre itself. I will see if I can get any mileage with that.
 
Is there a way to run the Batch Encode action on a group of files from the command line over ssh?

Or am I just as well using the HandBrakeCLI with nohup to ensure that the process isn't halted on disconnecting?

It would be better to be able to use Batch Encode action as it would tag and label my movie and Hazel could then copy it across to my server and add it to iTunes.

Any thoughts?
 
Is there a way to run the Batch Encode action on a group of files from the command line over ssh?

Or am I just as well using the HandBrakeCLI with nohup to ensure that the process isn't halted on disconnecting?

It would be better to be able to use Batch Encode action as it would tag and label my movie and Hazel could then copy it across to my server and add it to iTunes.

Any thoughts?

Screen.

In command line via ssh, you can run 'screen'. It allows a terminal session that you can detach from and still have the process running.

Here is a brutal quick run tutorial of how I use it.

Ssh into computer, type screen. This opens a screen. Run a command, let it do its thing. If you get disconnected or want to detach, press Control+a, release and then hit D. This detaches the screen, now your in the first session.
You can exit or if you want to reattach to that screen to see the progress, type in screen -R -D

Now its back on your screen.

Play with it with simple things until you figure out how it works. Google will help you as well with more options.
 
Screen.

In command line via ssh, you can run 'screen'. It allows a terminal session that you can detach from and still have the process running.

Here is a brutal quick run tutorial of how I use it.

Ssh into computer, type screen. This opens a screen. Run a command, let it do its thing. If you get disconnected or want to detach, press Control+a, release and then hit D. This detaches the screen, now your in the first session.
You can exit or if you want to reattach to that screen to see the progress, type in screen -R -D

Now its back on your screen.

Play with it with simple things until you figure out how it works. Google will help you as well with more options.

Sounds similar to nohup, but more useful.

I've got the HandBrakeCLI working no problem over SSH. But is it possible to run mac.jedi's Batch Encode action from the terminal over ssh? I haven't worked out how to do that yet.
 
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5)

sandyjmacdonald said:
HackerJL said:
Screen.

In command line via ssh, you can run 'screen'. It allows a terminal session that you can detach from and still have the process running.

Here is a brutal quick run tutorial of how I use it.

Ssh into computer, type screen. This opens a screen. Run a command, let it do its thing. If you get disconnected or want to detach, press Control+a, release and then hit D. This detaches the screen, now your in the first session.
You can exit or if you want to reattach to that screen to see the progress, type in screen -R -D

Now its back on your screen.

Play with it with simple things until you figure out how it works. Google will help you as well with more options.

Sounds similar to nohup, but more useful.

I've got the HandBrakeCLI working no problem over SSH. But is it possible to run mac.jedi's Batch Encode action from the terminal over ssh? I haven't worked out how to do that yet.

Over ssh, I'd just use the "automator" command. Type: automator "~/Library/Services/Batch Encode • Batch Encode.workflow"

It should run Batch Encode just as if you selected the Service, but you won't get the output from Terminal.
 
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5)



Over ssh, I'd just use the "automator" command. Type: automator "~/Library/Services/Batch Encode • Batch Encode.workflow"

It should run Batch Encode just as if you selected the Service, but you won't get the output from Terminal.

Thanks. How do I tell it which files to act on? I'm a bit of a noob to all this.
 
Thanks. How do I tell it which files to act on? I'm a bit of a noob to all this.

The method I listed in my previous post is the easiest, and will act on any sources found in the TV or Movie folders you set up in the Batch Encode.workflow Service.

There's also a way to do this with the Batch Encode (Finder).workflow if you want to specify the sources manually.

Note: Pipe the input folders as a list with each source on its own line. Here's an example:

Code:
echo -e "/Volumes/IRON_MAN_D1\n/Volumes/DVD_VIDEO" | automator -i - "/Users/username/Library/Services/Batch Rip • Batch Rip (Finder).workflow"

In Terminal, Type "man automator" for more info.
 
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5)

sandyjmacdonald said:
Awesome. You rule mac.jedi.

Thanks! Those were really good questions. There are a lot of crazy things you can do with Automator. At one time I even set up a Rule in Mac Mail that would trigger an encode script by email :eek:
 
The previous code I posted was to actually move the file. Another option would be to have Hazel rename the files in a separate rule. Then have another rule move only the tagged files.

Code:
mp4infoPath="/usr/local/bin/mp4info"
getGenre=`"$mp4infoPath" "$1"`
fileNameNoExtension=`basename "$1" .m4v`
fileDir=`dirname "$1"`
untaggedFileName="${fileNameNoExtension}-untagged.m4v"
taggedFileName="${fileNameNoExtension}-tagged.m4v"
if [ -z "$getGenre" ]; then
	# Rename File if no genre is found
	mv "$1" "${fileDir}/${untaggedFileName}"
else
	# Rename File if genre is found
	mv "$1" "${fileDir}/${taggedFileName}"
fi

I ran this on a few files, and they all were renamed as -tagged. Which they are not. I can see the batch encoder didnt tag them, since the filenames were not correct at the time of encoding, it couldnt tag them. I cant tell you much more than that, I dont script enough to do any troubleshooting
 
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5)

HackerJL said:
The previous code I posted was to actually move the file. Another option would be to have Hazel rename the files in a separate rule. Then have another rule move only the tagged files.

Code:
mp4infoPath="/usr/local/bin/mp4info"
getGenre=`"$mp4infoPath" "$1" | grep "Genre"`
fileNameNoExtension=`basename "$1" .m4v`
fileDir=`dirname "$1"`
untaggedFileName="${fileNameNoExtension}-untagged.m4v"
taggedFileName="${fileNameNoExtension}-tagged.m4v"
if [ -z "$getGenre" ]; then
	# Rename File if no genre is found
	mv "$1" "${fileDir}/${untaggedFileName}"
else
	# Rename File if genre is found
	mv "$1" "${fileDir}/${taggedFileName}"
fi

I ran this on a few files, and they all were renamed as -tagged. Which they are not. I can see the batch encoder didnt tag them, since the filenames were not correct at the time of encoding, it couldnt tag them. I cant tell you much more than that, I dont script enough to do any troubleshooting

I tested it and it looks like I forgot to add the test for genre. :eek:

I'll update my original post, but the line that needs to be changed is listed below:

Code:
getGenre=`"$mp4infoPath" "$1" | grep "Genre"`
 
Last edited:
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5)



Sorry I may have mis-typed. Try changing the "if" argument to:
Code:
if [[ -z "$getGenre" ]]; then

I'm on my iPhone, so I can't test it for you, but I think that should work. Let me know if it doesn't and I'll check it out later today.

Will do. I have to wait till I have some more files to work with tomorrow, but I will try it
 
I ran this on a few files, and they all were renamed as -tagged. Which they are not. I can see the batch encoder didnt tag them, since the filenames were not correct at the time of encoding, it couldnt tag them. I cant tell you much more than that, I dont script enough to do any troubleshooting

I should also mention that mp4info needs to be installed for the script to work. It's installed along with the actions.
 
Thats the first thing I checked. Its there. Ill try this tomorrow.

I tested it, and the if statement was fine … but I forgot to add the test for genre. :eek:

I'll update my original post, but the line that needs to be changed is listed below:

Code:
getGenre=`"$mp4infoPath" "$1" | grep "Genre"`
 
The previous code I posted was to actually move the file. Another option would be to have Hazel rename the files in a separate rule. Then have another rule move only the tagged files.

Code:
mp4infoPath="/usr/local/bin/mp4info"
getGenre=`"$mp4infoPath" "$1" | grep "Genre"`
fileNameNoExtension=`basename "$1" .m4v`
fileDir=`dirname "$1"`
untaggedFileName="${fileNameNoExtension}-untagged.m4v"
taggedFileName="${fileNameNoExtension}-tagged.m4v"
if [ -z "$getGenre" ]; then
	# Rename File if no genre is found
	mv "$1" "${fileDir}/${untaggedFileName}"
else
	# Rename File if genre is found
	mv "$1" "${fileDir}/${taggedFileName}"
fi

I have confirmed this to work....nicely!
Many thanks.

Your commitment to this topic/thread is incredible!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.