Saturday, 13 June 2015

Creating a DCP from a Premiere Pro CC project with OpenDCP

 Here I'm describing how to create a DCP master for digital cinema projection. This here describes how to directly export from a Premiere Project using the media encoder.

Sound levels

Digital cinema projection requires average sound levels at -24dB. These are subjective levels and not peak levels which can go up to -1dB. Premiere has an amazing tool which is called "Loudness Radar" which shows you the loudness of your film. Just add it to your master bus and press edit.
Generally cinemas expect 5.1 sound: left, right, center, left surround, right surround and low frequency effects. Make sure that all your sequences are 5.1 sequences and not just stereo. As a rough guide dialogue is on the center speaker and the music on  L/R. So the most basic setup is one center speaker and L/R. A subwoofer (LFE) channel is also strongly recommended especially for the music when the L/R speakers are not full range.

Video levels

I assume here that you grade your film in Premiere with a calibrated monitor. I've got the Pantone Huey for the monitor calibration (two Philips 2215 OLED screens). Video levels should of course stay between 0% and 100% where I rarely go over 90%. I'm editing under Windows which gives me a gamma of 2.2 which seems to be pretty accurately mapped after calibration. That's important to understand why we need to use (sRGB complex) later on in OpenDCP (version 0.30).

Export with the media encoder


Video
 
The video is exported as a sequence of TIFF images. For a feature film at 2K that is about 1TB of hard drive space.
  • Make sure that the TIFF export is at the frame rate your project is. For example here the film was shot at a frame rate of 23.976FPS so the TIFF export should have the same frame rate.
  • The resolution is 1998x1080. If you shot in HD then Premiere will add transparent bars left and right to pad it up to 1998 pixels. OpenDCP will ignore the alpha channel and luckily the underlying transparent pixels are actually black so that the left / right bars cause no problems.
  • Tick the box "Use Maximum Render Quality"
  • Make sure that you have no transparent sections in the film. For example, the titler will use a transparent background by default, for example. However openDCP ignores the alpha channel which leads to messed up titles. Make sure that the titles have a black background.The same applies to fade to blacks via transparency (which you shouldn't do anyway).
  • After export check with GIMP that the correct levels have been exported. 0=black.
  • Take a note of the number of TIFF images we have exported. A feature film will have about 130,000 frames. This will be used for the audio conversion.
Audio


The sound files are exported as WAV files. Here, you need to create your own template probably. Cruical is that you export the audio streams separately: 48kHz, 24bits and mono. After export you get files like "myfilm_1.wav", "myfilm_2.wav" etc. Here is the mapping:
1=L
2=R
3=C
4=LFE
5=Ls
6=Rs

If you have any other framerate than 24fps you need to change the speed of the audio. In our case the film was shot at 23.976fps but will play at 24fps. So we need to speed up the film by 0.1%. However a better approach is to calculate the total number of samples of your film from the number of frames we have. Since we have exported a numbered TIFF sequence we know how many frames we have. On a DCP the frame rate is 24fps and the audio sample rate is 48kHz which means we need to have exactly 2000 samples / frame. So the total number of samples needs to be = number of frames * 2000. Adobe Audition is perfect for this purpose because you can set it to display everything in audio samples.

Use the effect Stretch and Pitch. The algorithm "Audition" is the one to choose and then just "Stretch". If you convert from 23.976 to 24fps this means that the film will play 0.1% faster so the stretch is 99.9%. Audition might change the duration from a multiple of 2000 to something slightly longer. In this case it decided to add to the film 9 audio samples which is of course not audible.At the end you should have 6 audio files normalised to a frame rate of 24fps.


Creating a DCP compatible drive

Hardware

The DCP is shipped on a 500GB hard drive which is inside of a CRU DataPort DX115 or DX115DC. The right part shows the actual DX115 carrier which contains the hard drive. I used a pretty standard 500GB hard drive. As long as it's SATA it should be fine. The docking station is an adapter which allows a SATA connection and a USB connection. Beware: not an eSATA connection which is very annoying. For proper testing the SATA connection is required. Connect a SATA cable to one of the free SATA slots inside of you your computer and run it to the docking station.
Alternatively buy an internal docking station which fits into a standard DVD drive slot. This is actually the "proper" method because this internal docking station is used in the DCP servers and allows hot swapping. It is very elegant in that you can plug in the drive while the server is running and Linux can mount it automatically. Removal of the drive can also happen during operation.

Linux

Time to reboot to Ubuntu Linux or in my case I have a separate Linux computer which talks to the windows box via a samba share.

Formatting the drive

The drive needs to be formatted as EXT3. This is probably the most risky step because you need to format the external drive and not your operating system (!). Type dmesg and have a look which drive is associated with your external drive:
[  139.684652] sd 7:0:0:0: [sdd] 976773168 512-byte logical blocks: (500 GB/465 GiB)
[  139.684689] sd 7:0:0:0: Attached scsi generic sg4 type 0
[  139.684712] sd 7:0:0:0: [sdd] Write Protect is off
[  139.684716] sd 7:0:0:0: [sdd] Mode Sense: 00 3a 00 00
[  139.684746] sd 7:0:0:0: [sdd] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  139.705147]  sdd: sdd1
[  139.705360] sd 7:0:0:0: [sdd] Attached SCSI disk
[  273.000188]  sdd: sdd1
[  429.766469]  sdd: sdd1
In this case plugging in the external drive gives you the device /dev/sdd. To be safe you should use fdisk with "fdisk /dev/sdd" and delete all particions and then create one primary Linux partition. It's menu guided so not very difficult.
Then you need to format this partition with:
sudo mkfs.ext2 -I 128 -j /dev/sdd1
This creates an EXT3 file system with an inode size of 128 bytes. Some people had difficulties with inode size of 256 on older servers but that was in 2008. Modern servers should all support the now default inode size of 256 but to be safe just force the formatter to use an inode size of 128. The option "-j" creates an EXT3 filesystem. However, also an EXT2 should do because it's downward compatible. Again, better to create an EXT3 even if that's not required by the DCP standard and a journal pretty useless in a read only filesystem.
Mount the newly created drive with:
sudo mount /dev/sdd1 /mnt
and then change permissions that you can write to it as a normal user:
sudo chmod a+rwx /mnt

Using openDCP

What I'm describing here has been done under both Ubuntu and Windows with OpenDCP (https://www.opendcp.org/). Download the ununtu package and install it with "sudo dpkg -i myopendcppackage.deb". Then you are ready to go. If dpkg moans about missing packages just start your favourite package manager and install the missing packages and re-run dpkg. For Windows there is a standard installer. I've done the JPEG2000 conversion under Windows by writing it on the samba share and then done the rest under Linux.

Creating the JPEG2000 files

The TIFFs need to be converted to JPEG2000 files and into the XYZ colour space. This can be done by the command line tools or by the openDCP gui. I used the GUI for it which shown here.
I just left the settings as they are. Important here is that the framerate is 24P and that the source colour space is 'sRGB complex'and that there is a conversion to the XYZ colour space. It's important to use 'sRGB complex' in version 0.30.0 because 'sRGB' will give you crushed blacks. 'sRGB complex' is actually the correct conversion between sRGB and XYZ whereas 'sRGB' in the settings is a hack to fix problems when using Aftereffects for the export.
BTW, don't panic: the preview stays black. Check at the end that all images have been converted. If there are any problems then use the command line tool instead but in my case everything went fine. If you load the JPEG2000 images into GIMp you will notice that they will look hazy and with the wrong contrast. This is normal.

Creating the MXF files

The actual files which are played on the DCP server are MXF files. There is one for audio and one for video. Again, I used the graphical tools to create the MXF files.

Picture

The MXF containing the picture is created again with the "opendcp" GUI. Select "MXF" and then JPEG2000, SMPTE and 24 frames per second. Specify the directory where all the JPEG2000 files reside and the output directory which should be on the EXT3 formatted external drive.
Both, the scanning of the directory and also the conversion will take a while so be patient. Alternatively you could use the command line tool:
opendcp_mxf -i . -o /mnt/myfilm_video.mxf
assuming that the input images are in the current directory and the output MXF goes straight onto the external drive.

Sound


The sound is done in the same way but by selecting WAV in the uppermost drop down box. Select 5.1 surround sound (6 channels). The output MXF should be saved on the EXT3 formatted drive.
Just select all the separate wav files and then press Create MXF. This will probably just take a few minutes. As a curiosity there is no documentation how to create the sound MXF from the command line. You need to use the GUI.

Creating the XML files

The final step is to create the XML files which are the "glue" between the MXF files and contain the title and descriptions such as issuer and rating.
For the final step I switched to the command line tool because in the GUI version it's not clear what's happening to the actual files. The command line version won't move/delete any of the MXF files but just creates the XML files in the same directory. Run it in the directory of the external drive. In my case just called "/mnt" after "cd /mnt" (one line):

opendcp_xml --reel ./a_mugs_game_video.mxf ./a_mugs_game_sound.mxf --title A_Mugs_Game --annotation OpenDCP_CPL --issuer BratwurstAndHaggis --kind feature

Don't forget to properly un-mount the drive before unplugging or just shut down the computer. 

To test your DCP plug the HD back in. If you have a USB connection then you should instantly see the files. If you have the internal SATA bay then it should show up in your dmesg when the drive is inserted into the computer. Mount it as described above and check that everything is there.

To test if it plays you can use the dcpPlayer for example. It plays the first 15 secs of your film or you could invest about £150 for a license which is worth every penny. This is only available under Windows and you need to install a driver which can mount the EXT3 filesystem.

Finished!

Credits:
Matt Cameron's DCP tutorial
A big thanks to the GFT for letting me to try out the DCP and especially Barney who gave me valuable feedback especially about the sound.

Saturday, 6 June 2015

Premiere 5.1 channel assignments

If you export 5.1 from Premiere as separate WAVs then Premiere annoyingly not calls them L,R,C but just 1.wav, 2.wav, etc.

Here is the mapping:

1=L
2=R
3=C
4=LFE
5=Ls
6=Rs