0

I'm on Mac OS 10.8.1, with ffmpeg-devel installed as a macport. I can run NeroAacEnc(win32) via Wine. I can transcode a movie into h264/aac using a simple ffmpeg command:

ffmpeg -i INPUT.MP4 -vcodec libx264 -acodec libfaac OUTPUT.MP4

Problem is, I prefer the sound of NeroAACEnc AAC encoder. Transcoding a wave audio file to AAC using Nero is also simple:

wine start neroAacEnc.exe -if INPUT.wav -of OUTPUT.mp4

How can I use ffmpeg for video encoding and NeroAACEnc for audio encoding in a single command? Pipes? Script? Automator? I am not good with any of these.

Help needed as I am lost. Thanks in advance.

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .