Thursday, October 18, 2012

Automating YouTube video creation and upload with Perl and Sibelius.

I was asked by the admin of stmaryssingers.com to explore the feasibility of converting their audio practice track library to videos on YouTube. Aside from the savings in bandwidth and storage space, the admin thinks there might be some possible click revenue towards the Singers costs.

I originally created the audio library of works that were being practiced by the choir by scanning, OCRing (Optical Music Recognition more accurately), importing the scans into Sibelius and exporting audio tracks for each part.

Originally it was purely to help me learn the music faster as I don't sight-read music and I don't have (music) keyboard skills. But it quickly became obvious that other choir members could use a little help so I put the tracks onto the website for easy access by members.

Creating YouTube videos from Sibelius .sib files.

After receiving the request to see if it were possible to create YT videos from .sib files, it occurred to me that a more recent version of Sibelius might have that facility. Sibelius has had Scorch for a long time, which creates music videos to be played on a website using the Scorch plugin. It shows the score together with a "bouncing ball" cursor which moves in time with the audio track. Scorch has had a very small takeup. YouTube on the other hand is a bit more popular and Avid announced a "feature-limited but cheap" version of Sibelius 7, called Sibelius 7 First, which exports a music score as a YouTube video (almost) exactly as I wanted.

The problem was that Sibelius doesn't have an automated facility to create "parts" videos. The audio practice tracks I created were re-mixed to emphasise each part. So the "Soprano" mix has the Soprano part in the centre of the sound stage, the Alto off to the right, the Tenor and Bass off to the left and the Piano even further off to the right. And so on for the other parts.

What I wanted to do was create an overlay image for each part which is mixed with the plain (SATB) video so that the particular part is highlighted while the others parts and accompaniment are slightly greyed out. Then I needed to replace the SATB audio file in the video with the audio re-mix for each part. 

And all of this has to be an automated script and the final step is to upload each part video to YouTube and update each description box to contain links to all the other parts in the work. 

It took me a few days but it works now (mostly).

Thankfully I had stored the Sibelius (.sib) file for each work on the website. But some of them are close to five years old and my knowledge of Sibelius was pretty minuscule back then. I've had to spend a lot of time cleaning up the .sib files to make them suitable to look at not simply listen to

The Process (so I can remember what to do next time).

1. Download and open the .sib file in Sibelius 6. Clean it up:
  • Use the Text/Delete Dynamics plugin to remove anything that changes the volume. This audio is for learning to sing the notes and it helps to be able to hear them.
  • Clean up the lyric lines. I'm only putting in one verse and chorus in the Soprano lyric line. I'm removing all other lyrics.
  • Open the Score Info window (File/Score Info) and set the composition name and the composer. YouTube requires these fields.
  • Reset the audio mix. When creating the audio library, I often saved the .sib file with one of the parts emphasised and it ruins the SATB export.
  • Show the staff rulers (View->Rulers->Staff Rulers) and adjust the inter-staff spacing: 29 from the top, 12 between each singing part, 14 between Piano staves.
  • Export Audio and save it as song_satb.aiff.
  • Run the Playback/SetPiano plugin to set all voices to Piano. Makes it easier to distinguish notes when learning.
  • Run the Playback/SetVoicePan to export an AIFF file for each vocal part in the score.
  • Adjust the names of the AIFF files so there is no digit in the filename if there is only one part in that voice e.g. song_a1.aiff should be song_a.aiff if there is only one alto part. But no need to change names if there is an alto1 and alto2 part.
  • Reset the mixer levels and the voice names in the score after running SetVoicePan.
  • Save the .sib file.
2. Open the .sib file in Sibelius 7 First and export it as a video:
  • Click 'File'
  • Click 'Export'
  • Click 'Video'
  • Deselect 'Use score paper texture'
  • Select Resolution as 'HD (720p)'
  • Edit the filename (default should be song.mov).
  • Click 'Export'
3. Run makmov.pl --file songfilename --title 'Song Title' --parts 's a t b' -o 33 -i 132
Or whatever params are appropriate.
  • makmov will pause after creating a single-frame PNG from the movie and the overlay PNGs (called 'gradient_*.png').
  • Use Preview to line up the single frame and the gradients. Stop the script and restart with different '-o' and '-i' values if they don't line up.
  • When all is OK, press 'Return' after the pause and process will create all the individual videos, upload them to YouTube and rewrite their description text with links to the other parts in the song.
Scripts are here.

No comments: