1

I need to encode thousands of MP4 H264 (mostly) files in a folder hierarchy to H265. Unfortunately Handbrake that I'd normally use have dismal support for batch processing of hierarchies.

The separate project HB Batch Encoder doesn't seem to support X265.

Preferably I'd want a method that can

  • Accept all source movie files in a selected hierarchy
  • Encode to X265 as good as Handbrake
  • Automatically pass thru AAC, re-encode any other audio
  • Output to the same directory as the source
  • Move the source to the Trash
  • Works on OS X 10.11

Can you suggest a tool and method for this that achieves this set of features?

2
  • Notice that starting from H264 encoded files to encode them into H265 might lead to a loss of quality as you are chaining two lossy encoders. Don't you have access to not-lossy-encoded masters ?
    – audionuma
    Commented Aug 5, 2016 at 18:27
  • Nope. These are just referral backups, so it's not quality critical. More space critical than quality.
    – MiB
    Commented Aug 8, 2016 at 13:58

1 Answer 1

2

FFMPEG of course. Being a command line application it can be easily integrate into any batch process no matter how convoluted, with the benefit that you get to learn about the power of the command line while you're at it (worked for me).

I haven't explored h.265 encoding much yet, but using settings I stole from the ffmpeg wiki here's how you'd encode a folder full of .movs:

cd "/the/path to/your/folder/"
mkdir "for the trash"
for i in *.mov; do;
  ffmpeg -i "$i" -c:v libx265 -preset slow -crf 25 -c:a copy "${i/\.mov/.mp4}"
  mv $i "./for the trash/"
done

Note that this won't delete the files, it will move them to a new folder called for the trash. This is because if you delete files with the command line they disappear instantly, you don't get a second chance if you change your mind or make a typo. There are trash command line utilities, but that's beyond the scope of this answer.

here's the wiki entry I based my ffmpeg command on, it does a good job of explaining the options used (I'm a bit thingy about lossy compression so I wound up the quality settings somewhat. I also used the slow preset which gives smaller file sizes. Depending on how much time you have you could use anything from ultrafast to placebo to achieve results that vary in file size but with the same quality. placebo being so named because the tiny bit of difference it makes at the expense of greatly increased processing time is mostly in your head):

In this example, we will use the following settings:

  • default CRF of 28. The CRF of 28 should visually correspond to libx264 video at CRF 23, but result in about half the file size.
  • medium preset. The preset determines how fast the encoding process will be – at the expense of compression efficiency. Put differently, if you choose ultrafast, the encoding process is going to run fast, but the file size will be larger when compared to medium. The visual quality will be the same. Valid presets are ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow and placebo.
  • AAC audio at 128 kBit/s. This uses the ffmpeg-internal encoder, but under AAC you will find info about more options.

ffmpeg -i input -c:v libx265 -preset medium -crf 28 -c:a aac -b:a 128k output.mp4

Handbrake also works on the command line.

And lastly if you are allergic to the colossal power lurking in terminal.app there are GUIs for ffmpeg, like this or this. Not sure how well they deal with batch encoding, and this is not a recommendation, because I don't use any of them. Time to toughen up and use the command line!

2
  • Thanks for the suggestion. I'll try ffmpeg on the command line. I'll report how it works out. However you seem to have missed my complaint was about Handbrake batch processing not respecting hierarchies, that is it misses files in a folder hierarchy.
    – MiB
    Commented Jul 19, 2016 at 13:38
  • @MiB if you're looking for a GUI for ffmpeg, try iffmpeg. I used it for a few days until I got a good handle on the command line tool. It handles batch encoding, but you have to play around to make sure you getting the settings right for everything in the batch. If you consider yourself tech-savvy, but aren't comfortable with the command line, I'd recommend it
    – NoahL
    Commented Mar 3, 2017 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.