Problems with 5.1 Audio Encodes

It has come to our attention that many of our trailers with 5.1 audio were improperly encoded where it only included the left, right, and center channels, omitting the rear-left, rear-right, and subwoofer channels. I’ve already reported the issue to the creator of mp4tools (the utility which I’ve been using to re-encode the raw files).

Here’s what the 6 channels look like if you open the mp4tools encoded file in Audacity:

bad encode

In the mean time, I’ve been learning and playing with ffmpeg and I’ve come across a set of options that seem to do the trick. I’ve created a bash alias that does the following:

ffmpeg -i "$1" -y -vcodec libx264 -crf 18.0 -preset veryslow -vf "scale=852:trunc(ow/a/2)*2" -acodec libfaac -ab 384k -ac 6 -f mp4 "${1%.*}-480p-HDTN.mp4"
ffmpeg -i "$1" -y -vcodec libx264 -crf 18.0 -preset veryslow -vf "scale=1280:trunc(ow/a/2)*2" -acodec libfaac -ab 384k -ac 6 -f mp4 "${1%.*}-720p-HDTN.mp4"
ffmpeg -i "$1" -y -vcodec libx264 -crf 18.0 -preset veryslow -vf "scale=1920:trunc(ow/a/2)*2" -acodec libfaac -ab 384k -ac 6 -f mp4 "${1%.*}-1080p-HDTN.mp4"

Here’s the explanation of the options:

  • -i "$1" means the 1st argument passed in is the input file
  • -y means always answer ‘yes’ to questions (e.g. overwriting files)
  • -vcodec libx264 means to re-encode the video using the x264 codec
  • -crf 18.0 refers to a quality of the encode (18 is visually lossless according to the FFmpeg and x264 Encoding Guide)
  • -preset veryslow means to use a slowest preset which will provide the best compression
  • -vf "scale=852:trunc(ow/a/2)*2" means to scale the video to have a width of 852px and a variable height that maintains the aspect ratio. By default, -1 is used for variable heights/widths, but because x264 requires height and width to be divisible by 2, trunc(ow/a/2)*2 is required (see bug #309)
  • -acodec libfaac means to re-encode the audio using faac
  • -ab 384k means to use a 384k audio bitrate
  • -ac 6 means there’s 6 audio channels
  • -f mp4 means that the file format should be mp4
  • "${1%.*}-480p-HDTN.mp4" means that the output file name should use the original filename, but drop the extension while appending -480p-HDTN.mp4

Here’s what the audio channels look like in Audacity when encoded properly:

good encode

I’ll try and find some time to fix the existing bad encodes. No guarantees on when they’ll all be fixed.

Update 1: Emmgunn from mp4tools has gotten back to me and apparently the culprit is the version of ffmpeg that comes with mp4tools and its inability to handle dtshdma audio streams.

Update 2: @willydearborn has brought to my attention that my new encodes are using a newer H.264 profile which won’t stream on the PS3. After looking into this, I’ve discovered that by using the the veryslow preset, it was using [email protected] for 480p encodes, [email protected] for 720p encodes, and [email protected] for 1080p encodes.

By using the default preset, it will use [email protected] for 480p encodes, [email protected] for 720p encodes, and [email protected] for 1080p encodes. The file size is a bit bigger, but change in quality is unnoticeable. Therefore I’ll be switching back to using the default preset.

If you ever want to manually set the profile and level, the options to pass in is: -profile:v PROFILE -level:v LEVEL (More details at FFmpeg and x264 Encoding Guide)

Update 3: As a rule of thumb, I usually encode 1080p @ 10Mbps, 720p @ 5Mbps, and 480p @ 2.5Mbps. But after reading up on libx264 and how the CRF value works, I’ve learnt there’s no reason to do a 2-pass encode anymore. 2-pass encodes were useful if you wanted to hit a certain bitrate or filesize, but all I really cared about was quality and I can certainly see why certain trailers would have a higher or lower bitrate.

I’ve gone with the suggested CRF value of 18 (visually lossless), but it tends to give encodes with slightly lower bitrates than I usually expect. I’ve played with CRF values between 15-18 and can’t really tell any difference besides the increased file size.

Attacks on DreamHost and Enabling CloudFlare

For the past 2 days, our site has been going up and down like a roller coaster due to attacks and connection issues at our webhost (DreamHost):

As a temporary fix (maybe permanent?) against the attacks, they’re limiting every account to only 3 simultaneous connections, which has created a new set of problems for us, causing what many of you saw yesterday as 503 Service Temporarily Unavailable.

For now, we’ve enabled CloudFlare on our site, hoping by having CloudFlare cache our site (which is mostly static), it would help relieve some of our simultaneous connections issues.

We’ve also reworked how our site caching worked, making it less agressive at expiring cache. You might end up seeing some stale pages once in awhile. Hopefully that’ll help too.

In the meantime, we’re looking into options for a more reliable webhost.

Yahoo! Redirection Script

Yahoo! has once again changed their API. Although I have discovered how to obtain the direct download URL, it’s only a temporary URL which expires quickly. That makes it unusable on our site.

Therefore, I’ve written a redirection script which runs some javascript that obtains and redirects you the temporary URL. At which point, you should be able to view and download the trailer. Unfortunately that means if you’re using a download utility or attempt to right click and save as…, it won’t work for you anymore.

I apologize for this inconvenience and if there’s any further development, I’ll be sure to let you know.

I also plan on updating the Yahoo! download tutorial shortly.

Happy Holidays!

Update 2013/01/07: How to save Yahoo! trailers

Option 1: Open the link in a new tab/window:
option 1

Option 2: Click Download when the trailer is playing:
option 2

New Mobile Site!

I’ve been meaning to bring up a mobile-friendly version of our site for some time. More and more people are accessing our site from smart phones and tablets and now with more and more devices supporting HD screens and having access to high speed LTE internet, it was a no-brainer that we needed a mobile-friendly site.

So I’m happy to introduce to you: m.hd-trailers.net

It’s not fully featured yet, but should be more than enough for browsing and watching HD trailers on your mobile device. If things go well, I’ll start redirecting mobile users from our main site to use our mobile site.

Let us know what you think or if you hit into issues. Enjoy! (^_^x)