Skip to main content

Topic: Mac OS X AAC command line encoder besides FAAC? (Read 19051 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • kcramer
  • [*]
Mac OS X AAC command line encoder besides FAAC?
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!

  • krmathis
  • [*][*][*][*][*]
Mac OS X AAC command line encoder besides FAAC?
Reply #1
What about 'afconvert'? A CoreAudio example application, following Xcode Tools.
Quote
afconvert - reads one audio file, writes it to another format. Good example of the power of CAAudioFile and use of the AudioConverter for codecs.


Code: [Select]
$ 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)

  • dbAmp
  • [*][*][*]
Mac OS X AAC command line encoder besides FAAC?
Reply #2
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.

  • kcramer
  • [*]
Mac OS X AAC command line encoder besides FAAC?
Reply #3
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.

  • nerd
  • [*]
Mac OS X AAC command line encoder besides FAAC?
Reply #4
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$

  • Maurits
  • [*][*][*][*]
Mac OS X AAC command line encoder besides FAAC?
Reply #5
Isn't this something you can let 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 is considered bad for audio quality?
  • Last Edit: 24 May, 2007, 02:11:56 PM by Maurits
There is a hidden message in the song at approximately 4:32. If played at half speed, Waters can be heard to say, "That was pretty avant-garde, wasn't it?"

  • nerd
  • [*]
Mac OS X AAC command line encoder besides FAAC?
Reply #6
Isn't this something you can let 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 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.

Mac OS X AAC command line encoder besides FAAC?
Reply #7
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,..


  • smok3
  • [*][*][*][*][*]
  • Moderator
Mac OS X AAC command line encoder besides FAAC?
Reply #8
Isn't this something you can let 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 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 , /audio section
- curently it does not handle metadata
- it works with tmp files
- its highly adaptable (edit the bash script)
PANIC: CPU 1: Cache Error (unrecoverable - dcache data) Eframe = 0x90000000208cf3b8
NOTICE - cpu 0 didn't dump TLB, may be hung

Mac OS X AAC command line encoder besides FAAC?
Reply #9
doesn't look like a command line tool,..

  • smok3
  • [*][*][*][*][*]
  • Moderator
Mac OS X AAC command line encoder besides FAAC?
Reply #10
Its bunch of bash scripts that call command line tools (they come packed in droplets), but scripts could be easily adapted to run standalone,...
  • Last Edit: 30 May, 2012, 03:45:09 PM by smok3
PANIC: CPU 1: Cache Error (unrecoverable - dcache data) Eframe = 0x90000000208cf3b8
NOTICE - cpu 0 didn't dump TLB, may be hung

  • Nessuno
  • [*][*][*][*]
Mac OS X AAC command line encoder besides FAAC?
Reply #11
Maybe  XLD in batch mode is all you need.
... I live by long distance.

Mac OS X AAC command line encoder besides FAAC?
Reply #12
Couldn't the command line version of XLD do what you're after ?

Mac OS X AAC command line encoder besides FAAC?
Reply #13
I'll look into it, never heard of XLD before.

Mac OS X AAC command line encoder besides FAAC?
Reply #14
XLD is the holiy grail for OS X. http://tmkk.pv.land.to/xld/index_e.html

Mac OS X AAC command line encoder besides FAAC?
Reply #15
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?

  • Nessuno
  • [*][*][*][*]
Mac OS X AAC command line encoder besides FAAC?
Reply #16
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.
... I live by long distance.

Mac OS X AAC command line encoder besides FAAC?
Reply #17
[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,..

  • Dario
  • [*][*][*]
Mac OS X AAC command line encoder besides FAAC?
Reply #18
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.

  • Nessuno
  • [*][*][*][*]
Mac OS X AAC command line encoder besides FAAC?
Reply #19
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:

Code: [Select]
xld [-f format] [-o outpath] input_file

... I live by long distance.

Mac OS X AAC command line encoder besides FAAC?
Reply #20
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:
Code: [Select]
./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:
Quote
Illegal instruction: 4


Cu Selur

  • Nessuno
  • [*][*][*][*]
Mac OS X AAC command line encoder besides FAAC?
Reply #21
Code: [Select]
./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:
Quote
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.
... I live by long distance.

Mac OS X AAC command line encoder besides FAAC?
Reply #22
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,...)

  • Nessuno
  • [*][*][*][*]
Mac OS X AAC command line encoder besides FAAC?
Reply #23
if it doesn't work with pipes it's not interesting for me,...

Have you made the temporary file test to verify?
... I live by long distance.

Mac OS X AAC command line encoder besides FAAC?
Reply #24
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,..