<p><a href="http://ffmpeg.org" rel="nofollow noreferrer">FFMPEG</a> 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). </p>

<p>I haven't explored h.265 encoding much yet, but using settings I stole from the <a href="https://trac.ffmpeg.org/wiki/Encode/H.265" rel="nofollow noreferrer">ffmpeg wiki</a> here's how you'd encode a folder full of .movs:</p>

<pre><code>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
</code></pre>

<p>Note that this won't delete the files, it will move them to a new folder called <strong>for the trash</strong>. 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 <a href="http://hasseg.org/trash/" rel="nofollow noreferrer">trash command line utilities</a>, but that's beyond the scope of this answer.</p>

<p>here's the <a href="https://trac.ffmpeg.org/wiki/Encode/H.265" rel="nofollow noreferrer">wiki</a> 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 <code>ultrafast</code> to <code>placebo</code> to achieve results that vary in file size but with the same quality. <code>placebo</code> being so named because the tiny bit of difference it makes at the expense of greatly increased processing time is mostly in your head):</p>

<blockquote>
  <p>In this example, we will use the following settings:</p>
  
  <ul>
  <li>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.</li>
  <li>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.</li>
  <li>AAC audio at 128 kBit/s. This uses the ffmpeg-internal encoder, but under AAC you will find info about more options. </li>
  </ul>
  
  <p>ffmpeg -i input -c:v libx265 -preset medium -crf 28 -c:a aac -b:a 128k
  output.mp4</p>
</blockquote>

<p>Handbrake <a href="https://trac.handbrake.fr/wiki/CLIGuide" rel="nofollow noreferrer">also works on the command line</a>. </p>

<p>And lastly if you are allergic to the colossal power lurking in terminal.app there are GUIs for ffmpeg, like <a href="http://www.ffmpegx.com/" rel="nofollow noreferrer">this</a> or <a href="http://www.iffmpeg.com/index.html" rel="nofollow noreferrer">this</a>. 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!</p>

CC BY-SA 3.0
2016-07-19T13:38:53.017Z
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
CC BY-SA 3.0
2017-03-03T05:50:32.007Z
@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
CC BY-SA 3.0
2016-07-06T00:07:18.973Z
2017-03-03T05:55:12.397Z
2017-03-03T05:55:12.397Z
stib
<p>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.</p>

<p>The separate project HB Batch Encoder doesn't seem to support X265.</p>

<p>Preferably I'd want a method that can </p>

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

<p>Can you suggest a tool and method for this that achieves this set of features?</p>

CC BY-SA 3.0
2016-08-05T18:27:11.007Z
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
CC BY-SA 3.0
2016-08-08T13:58:40.647Z
Nope. These are just referral backups, so it's not quality critical. More space critical than quality.
MiB
<software-recommendation><encoding><conversion><mp4><osx>
Batch encode to X265 on the Mac
MiB
# Batch encode to X265 on the Mac

(Asked by: username_0 on 2016-07-05)

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?

**Tags:** software-recommendation, encoding, conversion, mp4, osx

> **Comments:**
> **username_1**: 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 ?  
> **username_0**: Nope. These are just referral backups, so it's not quality critical. More space critical than quality.  

---

## 1 answers

### Answer by username_2 on 2016-07-06. Score: 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!

> **Comments:**
> **username_0**: 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.  
> **username_3**: @username_0 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  

---

