Convert ISO639 codes to Decimal, DVD Studio Pro Language settings, SPRM0 values

Have you ever wanted to know what the language codes are for a DVD? They are held as a decimal number in SPRM0 and you can use this value in lots of ways.

For example, knowing the setting for the language code in a DVD player means that you can force your DVD to start up in that language. However, knowing the values your authoring app uses for language codes is also valuable.

Working in DVD Studio Pro it is easy enough to change the simulation preferences to display a different language for the project. You can then examine that value when the simulation takes place, but given the sheer number of different languages it would take someone with the patience of a saint to switch all of the preferences one at a time and then see what the values were.

If you use an application like Haxor (Mac only), you can easily convert ASCII to decimal… but only one at a time. Equally frustrating as a job, and also not converting them to the values that DVDs use.

So I talked with Alex Blanc at Ultralab and he wrote a PHP script to do the job – I supplied the text file with the language codes in ASCII characters, and we were able to export a comma separated list which went in to Excel.

Now, for whatever reason, DVD Studio Pro (and DVD Lab Pro on a PC, and probably ALL authoring apps) add 8224 to the decimal value of the letters. Why? I have no idea!

It was a simple matter to have Excel add that value to every entry and then output the necessary numbers.

OK – I’ll agree with you – not a fantastic market for this piece of knowledge, but all the same it’s another piece of the jigsaw for those wanting to fill in the gaps.

Download the resulting file (in pdf format) here.

DVD Studio Pro, Play All, DVDSP scripting

I have been thinking more about how to create a ‘play all’ scenario on a DVD Studio Pro project and reduce the number of scripts to achieve it.

For those who haven’t yet got there, you can achieve a ‘Play All’ system by using stories in your project as long as your footage is all in one track. If, like lots of folk, you have several different tracks that you want to link together in a ‘Play All’ system you have to use scripts.

My advice is first of all to not use lots of tracks, it makes a lot more sense to keep everything in one place and go from there, but if you have already got it set up, this is what you need to do.

First off, understand the principle here. When a user selects ‘play all’ from your menu you need to set up a ‘flag’ so that when a track finishes the player knows that you came from the ‘play all’ button and will go to the next track in the sequence. Easy enough… set the play all button to go to the following script:

mov GPRM0, 1
Jump Track 1

I assume you have not yet used this GPRM, but if you have (and you need to keep it for that use), just choose another free one from the 8 available.

When the track finishes playing the ‘end jump’ will normally take you back to the menu. However, we need to set it to go to a script which first looks to see if the ‘play all flag’ is set. If it is then you need to go to the next track, but if not you go to the menu button for that track. Again, this is easy enough… but could get tedious to set up if you have a lot of tracks.

Here’s where it gets interesting. Imagine a menu with four buttons in a project with three tracks. Each of the first three buttons plays the relevant track, but the fourth button is the play all button. We can use the button number to help us decide if we are in a play all situation or not. Furthermore, DVD Studio Pro has a feature called ‘GPRM based button jumps’. What this means is that you can automatically insert the button number into a script to avoid using lots of script lines and ‘if’ statements. Very handy!

So now, instead of setting a simple flag when a menu button is selected, try setting every menu button to go to this script instead:

mov GPRM0, SPRM8
div GPRM0, 1024
goto 8 If(GPRM0 = 4)
mov GPRM1, 0
Jump Track 1 If(GPRM0 = 1)
Jump Track 2 If(GPRM0 = 2)
Jump Track 3 If(GPRM0 = 3)
mov GPRM1, 1
Jump Track 1

“What the heck is it doing?” I hear you ask!

OK, in this script we are using the automatic button number tracking to tell us which button you came from. SPRM8 is the system register which keeps track of which menu button has been used, and it starts at a value of 1024 for the first button, increasing in jumps of 1024 at a time. So in line 1 we place the value of the button into a register (in this case GPRM0) and then in line 2 we divide it to get single digit integers (1, 2, 3 or 4) to relate to the actual button number on the menu.

If you came from button 4 then you would jump ahead in the script to the place where GPRM1 is set to indicate this is a ‘play all’ situation – GPRM1 is set to ‘1’ and track 1 plays. However, if you are *not* in a play all situation you will have come from any other button, so reading the button number means the track attached to that button will play (this is what lines 4-7 are doing). Just to be sure, line 4 is setting GPRM1 to have no value, and this is important later on.

Now, the end jump for each track can go to a small script which looks to see if GPRM1 has a value in it. If it does, the next track plays, if not you go back to the menu and the button that you came from. For the end jump of Track 1 this will be:

Jump Track 2 If(GPRM1 = 1)
Jump MainMenu [GPRM0]

Line 1 here will take you on to the second track only if you came from the play all button (if you did then GPRM1 would be 1). If you didn’t, then line 2 kicks into action and this is where the GPRM based button jump comes in. Remember in the big script at the top where we put the button value into GPRM0? Well, it stays in there until something changes it. Nothing has changed it because we’ve only played the track, so the value is as it was. If you came from button 1 on the menu, you now go back to that button on the menu. You *could* get it to advance one button if you want so that all the viewer has to do is press ‘play’ on their handset, but I prefer to return them to where they were. It just seems more logical, somehow.

Now, the really cool stuff happens when the viewer is watching a ‘play all’ situation and wants to have a break from it. They can press the menu button again if they want to (or the pause) and they will go back to the menu. If they are very savvy DVD watchers they will know that simply pressing the menu button a second time will return them to the place they were last at – no values get changed, everything continues as normal.

However, what if they are bored with watching Track 1 in the ‘play all’ and now want to skip ahead to play ONLY Track 2? Normally, the value in GPRM0 wouldn’t get changed, Track 2 would play and then go in to Track 3! Agh! BUT… in the script above, since every menu button points to it, the value *does* get changed if the user makes a new choice… and so the ‘Play All’ is stopped! The new choice only will play and then go back to the menu.

Phew! Lots of words to describe a very simple thing – certainly easier to do than to describe. The next bit will be to see if I can reduce this still further so that in one script we can set up a play all, remove it and automatically keep track of which track has played (which means no small end jump scripts… just one master script to control it all).

Watch this space!