Has anyone found a command line AAC encoder that will use QuickTime/iTunes to encode files?
I want to automate converting all my FLAC files to AAC (m4a) and I can do it with FAAC but I would prefer the quality of the QT/iTunes encoder. It seems like it wouldn't be hard for someone to write a small command line application that uses the CoreAudio API to do this work.
Has anyone seen such a tool? I've had no luck finding one.
Thanks!
What about 'afconvert'? A CoreAudio example application, following Xcode Tools.
afconvert - reads one audio file, writes it to another format. Good example of the power of CAAudioFile and use of the AudioConverter for codecs.
$ afconvert
Usage:
afconvert [option...] input_file [output_file]
Options: (may appear before or after arguments)
{ -f | --file } file_format:
'adts' = AAC ADTS (.aac, .adts)
data_formats: 'aac '
'ac-3' = AC3 (.ac3)
data_formats: 'ac-3'
'AIFC' = AIFC (.aif, .aiff, .aifc)
data_formats: BEI8 BEI16 BEI24 BEI32 BEF32
BEF64 'ulaw' 'alaw' 'MAC3' 'MAC6' 'ima4'
'QDMC' 'QDM2' 'Qclp' 'agsm'
'AIFF' = AIFF (.aif, .aiff)
data_formats: BEI8 BEI16 BEI24 BEI32
'caff' = Apple CAF File (.caf)
data_formats: '.mp3' 'MAC3' 'MAC6' 'QDM2' 'QDMC'
'Qclp' 'Qclq' 'TS\x00\x02' 'TS\x00\x06' 'TS\x00\x07' 'TS\x00\x11'
'TS\x00E' 'TS\x00U' 'WMA1' 'WMA2' 'WMA3' 'aac '
'agsm' 'alac' 'alaw' 'drms' 'dvca' 'dvi '
'ima4' 'lpc ' BEI8 BEI16 BEI24 BEI32
BEF32 BEF64 LEI16 LEI24 LEI32 LEF32
LEF64 'ms\x00\x02' 'ms\x00\x11' 'ms\x001' 'ms\x00U' 'samr'
'ulaw' 'vdva'
'MPG3' = MPEG Layer 3 (.mp3, .mpeg)
data_formats: '.mp3'
'mp4f' = MPEG4 Audio (.mp4)
data_formats: 'aac '
'm4af' = MPEG4 Audio (.m4a)
data_formats: 'aac ' 'alac'
'NeXT' = NeXT/Sun (.snd, .au)
data_formats: BEI8 BEI16 BEI24 BEI32 BEF32
BEF64 'ulaw'
'Sd2f' = Sound Designer II (.sd2)
data_formats: BEI8 BEI16 BEI24 BEI32
'WAVE' = WAVE (.wav)
data_formats: LEUI8 LEI16 LEI24 LEI32 LEF32
LEF64 'ulaw' 'alaw'
{ -d | --data } data_format[@sample_rate_hz][/format_flags][#frames_per_packet] :
[-][BE|LE]{F|[U]I}{8|16|24|32|64} (PCM)
e.g. BEI16 F32@44100
or a data format appropriate to file format, as above
format_flags: hex digits, e.g. '80'
bitdepth on non-PCM formats can be specified, e.g.: alac-24
Frames per packet can be specified for some encoders, e.g.: samr#12
{ -c | --channels } number_of_channels
add/remove channels without regard to order
{ -l | --channellayout } layout_tag
layout_tag: name of a constant from CoreAudioTypes.h
(prefix "kAudioChannelLayoutTag_" may be omitted)
if specified once, applies to output file; if twice, the first
applies to the input file, the second to the output file
{ -b | --bitrate } bit_rate_bps
e.g. 128000
{ -q | --quality } codec_quality
codec_quality: 0-127
{ -r | --src-quality } src_quality
src_quality (sample rate converter quality): 0-127
{ -v | --verbose }
print progress verbosely
{ -s | --strategy } strategy
bitrate strategy for encoded file
0 for CBR, 1 for ABR, 2 for VBR
{ -t | --tag }
If encoding to CAF, store the source file's format and name in a user chunk.
If decoding from CAF, use the destination format and filename found in a user chunk.
--prime-method method
decode priming method (see AudioConverter.h)
This sounds like it is something that could be done with an AppleScript. If one already exists, it's probably at Doug's AppleScripts for iTunes (http://www.dougscripts.com/).
afconvert looks very good. I may have to change the application so it can read from stdin though. My conversion process relies on chaining applications together.
I guess I missed that when browsing the XCode stuff.
Thanks for all the suggestions.
afconvert looks very good. I may have to change the application so it can read from stdin though. My conversion process relies on chaining applications together.
I guess I missed that when browsing the XCode stuff.
Thanks for all the suggestions.
I'm looking for a mp3 to aac converter. I compiled afconvert, but I get a "Couldn't set file's length (-66566)" error.
here is the command I try. (i've also tried several others)
~/afconvert -v -f "mp4f" -d "aac " she_waits_mix.wav.mp3 test.mp4
and here is the output...
Input file: she_waits_mix.wav.mp3, 6276096 frames
Formats:
Input file 2 ch, 44100 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame
Output file 2 ch, 44100 Hz, 'aac ' (0x00000002) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Stereo
Input client 2 ch, 44100 Hz, 'lpcm' (0x00000009) 32-bit little-endian float
AudioConverter 0x180ce84 [0x319cc0]:
CodecConverter 0x319ec0
Input: 2 ch, 44100 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame
Output: 2 ch, 44100 Hz, 'lpcm' (0x00000009) 32-bit little-endian float
Output client 2 ch, 44100 Hz, 'lpcm' (0x00000009) 32-bit little-endian float
AudioConverter 0x180ce8c [0x31a0c0]:
CodecConverter 0x31a2e0
Input: 2 ch, 44100 Hz, 'lpcm' (0x00000009) 32-bit little-endian float
Output: 2 ch, 44100 Hz, 'aac ' (0x00000002) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
error -66566: Couldn't set file's length
Error: Couldn't set file's length (-66566)
it looks like it's working, but it just can't write the file?
I have also tried running faac, and it looks like it can't open the orginal mp3 file.. but it's a fine mp3. I can play it with all the mp3 players. (I encoded it using lame)
coca:~/music_projects nerd$ faac she_waits_mix.wav.mp3 -o test.mp4a
Freeware Advanced Audio Coder
FAAC 1.25
Couldn't open input file she_waits_mix.wav.mp3
coca:~/music_projects nerd$
Isn't this something you can let Max (http://sbooth.org/Max/) handle? It can transcode straight from MP3 to AAC using the CoreAudio/iTunes/QuickTime encoder.
By the way, you are aware that lossy-to-lossy transcoding (http://wiki.hydrogenaudio.org/index.php?title=Transcoding) is considered bad for audio quality?
Isn't this something you can let Max (http://sbooth.org/Max/) handle? It can transcode straight from MP3 to AAC using the CoreAudio/iTunes/QuickTime encoder.
By the way, you are aware that lossy-to-lossy transcoding (http://wiki.hydrogenaudio.org/index.php?title=Transcoding) is considered bad for audio quality?
Thanks, Maurtis. I tried it out and it works for making a mp4. But I need to automate the process, that's one reason I wanted to use s command line app. Is there a way to automate with Max? if so It doesn't seem obvious.
On Windows/Linux I use ffmpeg/mencoder/mplayer for decoding, than sox for filtering and neroaacenc/qaac*/fhgaacenc*/flac/lame/oggenc/vo-aacenc(through ffmpeg) for encoding, since I want to do basically the same on mac I was wondering if anything has changed regarding aac command line encoders on mac since 2007?
faac and vo-aacenc(through ffmpeg) are command line encoders that support input via pipe, are there other alternatives on mac?
@kcramer: did you create a modified version of afconvert which supports input via stdin?
Cu Selur
Ps.: sorry, for 'reviving' this old thread but it exactly fits to my problem,..
Isn't this something you can let Max (http://sbooth.org/Max/) handle? It can transcode straight from MP3 to AAC using the CoreAudio/iTunes/QuickTime encoder.
By the way, you are aware that lossy-to-lossy transcoding (http://wiki.hydrogenaudio.org/index.php?title=Transcoding) is considered bad for audio quality?
Thanks, Maurtis. I tried it out and it works for making a mp4. But I need to automate the process, that's one reason I wanted to use s command line app. Is there a way to automate with Max? if so It doesn't seem obvious.
check my ffdrop http://forum.doom9.org/showthread.php?t=162621 (http://forum.doom9.org/showthread.php?t=162621) , /audio section
- curently it does not handle metadata
- it works with tmp files
- its highly adaptable (edit the bash script)
doesn't look like a command line tool,..
Its bunch of bash scripts that call command line tools (they come packed in droplets), but scripts could be easily adapted to run standalone,...
Maybe XLD in batch mode is all you need.
Couldn't the command line version of XLD do what you're after ?
I'll look into it, never heard of XLD before.
XLD is the holiy grail for OS X. http://tmkk.pv.land.to/xld/index_e.html (http://tmkk.pv.land.to/xld/index_e.html)
Is there some 'howto' with examples somewhere?
How to convert stuff that comes via stdin to aacl lc/he/hev2 with the command line xld?
Is there some 'howto' with examples somewhere?
How to convert stuff that comes via stdin to aacl lc/he/hev2 with the command line xld?
It's possible that you don't even need to use CLI at all: "batch mode" means that you set the encoding preferences and let XLD to do all the job to clone even a whole music library, scanning subfolders and transconding every track on the way, metadata included. Just File > Open the folder where you want to start.
It's generally faster and more efficient than a shell script because it's possible to set the number of concurrent jobs to run, making better use of multicore CPUs.
Here I have no Mac at hand, but it should be easy to figure our yourself just looking in the "batch" pane of preferences.
[qutoe]It's possible that you don't even need to use CLI at all[/quote]
BUT I want/need a command line tool not some gui,..
Even though I'm no Mac user, I'm quite certain that XLD can work as a command-line application and should be exactly what you're looking for.
BUT I want/need a command line tool not some gui,..
So the way to obtain a result is more important than the result itself?
Ok, you will have your reasons... I think this command line should solve your problem:
xld [-f format] [-o outpath] input_file
downloaded xld from (http://tmkk.pv.land.to/xld/index_e.html) but if I call xld it only mentions wav, aif, raw_big, raw_little as formats,..
calling xld with:
./ffmpeg -y -threads 2 -v -10 -i "/Users/Selur/Desktop/tmp/test DELAY -43ms__aid_1__14_13_23_631_01.ac3" -ac 6 -acodec pcm_s16le -f wav - | ./xld -f aif -o "/Users/Selur/Desktop/tmp/test DELAY -43ms__aid_1__14_13_23_631_02.aac" -
I just get:
Illegal instruction: 4
Cu Selur
./ffmpeg -y -threads 2 -v -10 -i "/Users/Selur/Desktop/tmp/test DELAY -43ms__aid_1__14_13_23_631_01.ac3" -ac 6 -acodec pcm_s16le -f wav - | ./xld -f aif -o "/Users/Selur/Desktop/tmp/test DELAY -43ms__aid_1__14_13_23_631_02.aac" -
I just get:
Illegal instruction: 4
Not sure if XLD works with pipes. Try to do it in two stages (e.g. generating a temp file and then deleting it) to see if all other options work.
if it doesn't work with pipes it's not interesting for me,...
(sadly I haven't found any documentation about the -d parameter, regarding what options are possible,...)
if it doesn't work with pipes it's not interesting for me,...
Have you made the temporary file test to verify?
yes. I also tried:
afconvert -f m4af sixChannel.wav test.aac
and ended up with:
Error: ExtAudioFileSetProperty ('cfmt') failed ('!dat')
-> no clue what's the problem,..
It seems there is something wrong in your wav files. I don't know ffmpeg options, anyway the command line you showed before seems strange to me: what's that -10 option and the minus sign right before the pipe? And in the first place, are you sure about the way wav handles multichannel? (I confess my complete ignorance on this matter)
"-v -10" forces ffmpeg to not output any infos (error/debug/status messages)
" - " sets the output to pipe
the ffmpeg part of the command line should be fine, I use it all the time,.. to feed stuff to oggenc/lame/faac
"-v -10" forces ffmpeg to not output any infos (error/debug/status messages)
" - " sets the output to pipe
Ah ok, so is -v loglevel (I just would have written -v 10 ) and "no output file specified means stdout".
the ffmpeg part of the command line should be fine, I use it all the time,.. to feed stuff to oggenc/lame/faac
So the troubles are on the AAC encoding side? Well, following the good old rules of thumb for troubleshooting, make a test run with the simplest case you can (i. e. two channel track) and try also to convert your current WAV files with a well known working AAC converter (say GUI version of XLD or xACT... if you can let yourself use a GUI once! )