I had so much hassle trying to find the best way to burn my short film to a Blu-ray disk, I almost opted to pay the big bucks and have it done professionally. All I wanted was a great looking film on disk, with no menus, that would play without skipping. But because physical media is on the way out, and Blu-ray never gained the popularity of DVD, it would prove to be anything but a straight forward task. Anyway, I found a way in the end. Here’s what I found out.
Codecs:
After some reading on forums it seems VC-1 and h264 are superior codecs to MPEG2. Many will say VC-1 is the superior codec.
Encoding:
After some research I found that something called Cinevision PSE is the software to use – notably for it’s Microsoft xScaler feature – but according to a forum post this is way out of my price range (also I could not find a way to buy it even if I wanted to – it might have been discontinued). The programs I do have are Compressor, Squeeze and Adobe Media Encoder, so I will try and use one of these.
Muxing and burning:
Finally there is the hassle of getting the thing burned in the end. I opted to mux separately from the burning to make sure my video and audio were not re-encoded. For the burning I used Toast Titanium 11. And you need an external USB connected Blu-ray writer of course.
The process:
1. Encoded the video
I started with VC-1. I’m on a Mac so only Flip4Mac or Squeeze can get the job done. Squeeze output a VC-1 file that was way too dark compared to the original. Maybe Squeeze is misinterpreting gamma tags in the source file, I don’t know. Also the quality was not all that, even at high bitrates.
I decided to go with h264. One forum showed how Apple Compressor won hands down compared to Adobe Media Encoder when it came to artefacts and keeping grain, so I decided to drop the Adobe program. In the end Compressor did not give me a satisfactory result either. There is a long trackingshot through a garden at the beginning of the film, and all the encoders had a hard time not creating artifacts in the foilage. I had other issues with Compressor like the surround setup, the lack of support for pcm sound and the limitations of the burn-to-disk option that made me look for alternatives. Also, I’m constantly worried about gamma-shift issues when using any Quicktime format, so I wanted to use a tiff image sequence as the source material instead of a ProRes-file.
After some more research I realised the pros use ffmpeg – a command line utility available for OSX, Windows and Linux. It’s very powerful and proved in the end to give superior results to anything else I tried. Inside ffmpeg is a version of the x264-library, an open source bundle of joy that (according to many experts) will never screw up your gamma, even when exporting to Quicktime!
Here’s what I did:
– ffmpeg is installed and used via the Terminal – best option is to install via Brew.
– To install Brew paste this in your Terminal window:
ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
– Make sure you run brew update after install
– To install ffmpeg type:
brew install ffmpeg
– Brew often comes up with a list of warnings, but you can ignore these if the library installed without errors.
– Now you’re ready to transcode your film!
– Here is the ffmpeg command that I ended up running for my film:
ffmpeg -r 25 -f image2 -start_number 0 -i $PATH$FILESTEM%08d.tif -an -tune film -deblock 0:0 -vf scale=1920:804,pad=1920:1080:0:138:black -preset veryslow -sar 1/1 -c:v libx264 -x264opts bluray-compat=1:level=4.1:keyint=25:open-gop=1:slices=4:tff=1:colorprim=bt709:colormatrix=bt709:bitrate=32000:vbv-maxrate=40000:vbv-bufsize=30000:me=umh:ref=4:nal-hrd=vbr:aud=1:b-pyramid=strict:fake-interlaced=1 -pix_fmt yuv420p -f h264 -r 25 output32_1p_opt_fi.264
This scales, “letterboxes” (pads) and converts my 2k (2048×858) SCOPE (2.39) 16-bit TIFF image sequence into a high-quality Blu-ray compliant raw h264-file. This file you can later use to mux your stream for the disk. I may have doubled up on some options just to be sure it was Blu-ray compliant. $PATH and $FILESTEM must of course be replaced with your path and filenames.
Here is a breif explenation of some of the switches used:
-f image2 means we’re reading an image sequence
-r 25 is the input framerate of this sequence. My film was shot on 25fps, but many shoot at 24 or 23.98 for cinema.
-i is where your source path goes. For a quick way to get the path, drag the file into the Terminal window from Finder. Make sure there is a space after -i.
-an removes any audio in the original file. We will mux with a 5.1 surround file later.
-tune film sets the optimisation style. Options are: film, animation or grain (best for those who have scanned actual film or where the grain quality is important).
-deblock 0:0 prevents blocking artifacts.
-preset veryslow is for the final output. For testing use fast (lower quality).
-f h264 is the output format.
bitrate=32000. Change this to find your perfect size and quality.
fake-interlaced=1 will make 25fps run as if it was progressive (1080p is not really possible at 25fps, but this does it). Remove if using 24fps.
The rest is stuff you need for Blu-ray compliance and quality.
Ending the filename in .264 will make sure you output a raw h264-file. Put .mov or .mp4 here for other uses.
The %08d is the key to the image sequence style: %08 means a sequence of 8 digits padded with zeros i.e. 00000001.tif –> 00000002.tif etc. If your sequence does not start at 0, be sure to specify the -start_number parameter, or it will fail.
Be sure to escape spaces in the path with a backslash (at least on OSX). (On a PC you should also escape the % with a %).
Read up on ffmpeg here. Also read here for a better understanding of the x264-library.
If you’re encoding from a video source, like an already letterboxed HD ProRes-file, this is the correct syntax.
ffmpeg -i $PATH$FILENAME.mov -an -tune film -deblock 0:0 -preset veryslow -sar 1/1 -c:v libx264 -x264opts bluray-compat=1:level=4.1:keyint=25:open-gop=1:slices=4:tff=1:colorprim=bt709:colormatrix=bt709:bitrate=32000:vbv-maxrate=40000:vbv-bufsize=30000:me=umh:ref=4:nal-hrd=vbr:aud=1:b-pyramid=strict:fake-interlaced=1 -pix_fmt yuv420p -f h264 -r 25 output32_1p_opt_fi.264
Encoding with these settings, for my 17-minute short on my iMac, took around 2 hours. I must say the results were of exceptional quality, better than any h264 export I did with any other method – almost as good as the ProRes file I got from the same source. There may be many reasons for this – especially going from uncompressed 16-bit tiff source files – but it looks like x264 is the best bet out there for creating great h264 results.
2. Encoded my audio
– I used Audacity to export AC3 from my surround file, but could easily have used ffmpeg for this as well (actually Audacity does use ffmpeg for this). In the end I opted to use the original lpcm (linear PCM) wav-file in the muxing though – not AC3. Blu-ray has this option for those who want high quality uncompressed sound on their films. Make sure your tracks are in the right order for surround – an LPCM file follows a different standard than an AC3 file. Check the link below for an in-depth explanation.
3. Mux
– I used tsMuxerGUI to create a Blu-ray iso-file of the .264 and the .wav file.
– It’s important to mux the stream yourself – this will make sure Toast will not re-encode your video or audio (which it has a tendency to do, even if you have the right settings and file types).
– Drag-and-drop the two files (.264 and .wav/.ac3) into the top window. Then select Blu-ray disk from the options below and hit “Start muxing”.
4. Burned the iso-file with Toast Titanium 11
– Get Toast Titanium 11
– Go to Copy and select Image File, burn ISO to disk or Blu-ray.
5. Test
– Make sure you test it. Not all Blu-ray players can handle the bandwidth and will skip. Both the audio and the video can be a problem I think. The high-bitrate versions played poorly on my iMac, but were smooth on the standalone Blu-ray player. Old school Blu-ray encoders recommend not going above 25 Mbit bitrate, to be compliant with all players. Using uncompressed LPCM sound also made the disk skip (even with low bitrate video) on my iMac.
Links
Audio:
http://www.afterdawn.com/guides/archive/afterdawn_blu-ray_encoding_tutorial_lesson_7-advanced_audio_processing.cfm
Video:
https://www.ffmpeg.org/ffmpeg-all.html
http://mewiki.project357.com/wiki/X264_Settings
http://www.x264bluray.com/home/1080i
http://evilsoup.wordpress.com/2013/02/10/general-ffmpeg-encoding-guide-2/
https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping