On Linux, I can use a pipe to create an M4A with neroAacEnc like so
ffmpeg -i input.mp4 -vn -f wav - | neroAacEnc -if - -ignorelength -q 0.5 -of output.m4a
You'd have to use wine neroAacEnc.exe
there, and I have no idea if the windows version running under wine can use pipes. In theory, the following should be able to do it all in one command (assuming you have an up-to-date ffmpeg):
ffmpeg -i input.mp4 -vn -f wav - | neroAacEnc -if - -ignorelength -q 0.5 -of - | ffmpeg -i - -i input.mp4 -map 1:v -map 0:a -c:a copy -c:v libx264 -crf 22 -preset veryfast output.mp4
But unfortunately, neroAacEnc seems to be able to take a pipe as input, or output to a pipe, but not both at once, so the above will not work, and you need to do it with two commands:
ffmpeg -i input.mp4 -vn -f wav - | neroAacEnc -if - -ignorelength -q 0.5 -of temp-audio.m4a
ffmpeg -i input.mp4 -i temp-audio.m4a -map 0:v -map 1:a -c:a copy -c:v libx264 -crf 22 -preset veryfast output.mp4
I can put this in a basic bash script (which AFAIK should work on OSX)
#!/bin/bash
ffmpeg -i "$1" -vn -f wav - | neroAacEnc -if - -ignorelength -q 0.5 -of "temp.${1%.*}.m4a"
ffmpeg -i "$1" -i "temp.${1%.*}.m4a" -map 0:v -map 1:a -c:a copy -c:v libx264 -crf 22 -preset veryfast "output.${1%.*}.m4v"
rm "temp.${1%.*}.m4a
exit 0
Save it somewhere in your $PATH as convert-to-M4V and mark it as executable, use it like this:
convert-to-M4V input.mov
To do every mov in a directory:
for f in *.mov; do convert-to-M4V "$f"; done
NOTE: I'm not on OSX, and I've never really used the command line on OSX, so some of this might not work/might need adaptation.
roAA
EDIT: Since you're on OSX, you should be able to use the (superior to neroAacEnc in some tests) quicktime AAC encoder, qaac, which may well have better support for pipes. And it's a native solution.
FOOTNOTE: You may also find useful this guide to encoding with x264 on ffmpeg, and this guide to neroAacEnc.