PDA

View Full Version : afconvert to convert ac3 to aac


B4tm4n
2nd December 2007, 13:49
I'm trying to use afconvert to convert an ac3 file in to an aac file.
The ac3 file is a stream extracted from a mkv using mkvextract.
And I'm getting no where here is how far I've got.

MacBook:~ B4tm4n$ afconvert -v -f mp4f -d aac -b 128000 /Users/B4tm4n/Desktop/\[mkvextract\]/audio2.ac3
Input file: audio2.ac3, 0 frames
Error: Couldn't set client format (-50)

What am I doing wrong, I just can't figure it out.

Here is the usage info from terminal.

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: '.mp1' '.mp2' '.mp3' 'FlAd' 'MAC3'
'MAC6' 'PesA' 'QDM2' 'QDMC' 'Qclp' 'Qclq'
'TS\x00\x02' 'TS\x00\x06' 'TS\x00\x07' 'TS\x00\x11' 'TS\x00E' 'TS\x00U'
'WMA1' 'WMA2' 'WMA3' 'XiVs' 'aac ' 'ac-3'
'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' 'ms\x01`'
'ms\x01a' 'ms \x00' '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)

If anyone can help me find the right order of commands I would be greatly thankfull.

Cheers.

mic64
4th December 2007, 11:06
Hi
I can't help you with afconvert, but here is a small script to convert ac3 too aac5.1 with faac and mplayer
mkfifo audiodump.pcm
faac -q 100 -I 5,6 -P -R 48000 -C 6 -X audiodump.pcm --mpeg-vers 4 --obj-type LC -o $2 & mplayer $1 -vo null -ao pcm:nowaveheader -channels 6

save it as aactoac3, amke it executbale
and run it like this
aactoac3 audio.ac3 audio.mp4.
File is PS3 compatible

B4tm4n
4th December 2007, 19:49
Hi
I can't help you with afconvert, but here is a small script to convert ac3 too aac5.1 with faac and mplayer
mkfifo audiodump.pcm
faac -q 100 -I 5,6 -P -R 48000 -C 6 -X audiodump.pcm --mpeg-vers 4 --obj-type LC -o $2 & mplayer $1 -vo null -ao pcm:nowaveheader -channels 6

save it as aactoac3, amke it executbale
and run it like this
aactoac3 audio.ac3 audio.mp4.
File is PS3 compatible


Thanks.
I tried it but got this error :

MacBook:~/Desktop/[mkvextract] B4tm4n$ aactoac3 audio.ac3 audio.mp4
Freeware Advanced Audio Coder
FAAC 1.24+ (Nov 29 2007) UNSTABLE

audiodump.pcm: No such file or directory
Couldn't open input file audiodump.pcm
MacBook:~/Desktop/[mkvextract] B4tm4n$

Thanks alot thats seems to be working. I got the stupid error above because I hadn't compiled mplayer, just downloaded the binary file.

Spoke too soon now I'm getting this error
MacBook:~/Desktop/[mkvextract] B4tm4n$ aactoac3 audio.ac3 audio.mp4
Freeware Advanced Audio Coder
FAAC 1.24+ (Nov 29 2007) UNSTABLE

audiodump.pcm: No such file or directory
Couldn't open input file audiodump.pcm
MPlayer dev-SVN-r25299-4.0.1 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz (Family: 6, Model: 15, Stepping: 6)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2

Playing audio.ac3.
libavformat file format detected.
[lavf] Audio stream found, -aid 0
==========================================================================
Opening audio decoder: [liba52] AC3 decoding with liba52
Using SSE optimized IMDCT transform
Using MMX optimized resampler
AUDIO: 48000 Hz, 6 ch, s16le, 384.0 kbit/8.33% (ratio: 48000->576000)
Selected audio codec: [a52] afm: liba52 (AC3-liba52)
==========================================================================
[AO PCM] File: audiodump.pcm (RAW PCM)
PCM: Samplerate: 48000Hz Channels: Stereo Format s16le
[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast
[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).
AO: [pcm] 48000Hz 6ch s16le (2 bytes per sample)
Video: no video
Starting playback...
a52: CRC check failed! (52.8) 0.7%
a52: error at resampling
A: 52.8 (52.8) of 52.9 (52.8) 0.7%

Exiting... (End of file)
MacBook:~/Desktop/[mkvextract] B4tm4n$

talen9
4th December 2007, 23:46
I think you might have a problem with the FIFO creation, which should be done by the "mkfifo audiodump.pcm" part of the script ... the problem resides in your OSX kernel version, which apparently wasn't compiled with FIFO support (I just google and found this (http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/mkfifo.2.html) man page).

Try and execute the following commands:
mkfifo audiodump.pcm
echo $?

and report the output (a number).
That number is 0 if the command executes correctly; otherwise, it will lead us to the correct origin of the problem.

B4tm4n
5th December 2007, 02:33
I think you might have a problem with the FIFO creation, which should be done by the "mkfifo audiodump.pcm" part of the script ... the problem resides in your OSX kernel version, which apparently wasn't compiled with FIFO support (I just google and found this (http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/mkfifo.2.html) man page).

Try and execute the following commands:
mkfifo audiodump.pcm
echo $?

and report the output (a number).
That number is 0 if the command executes correctly; otherwise, it will lead us to the correct origin of the problem.





I get 0.

MacBook:~ B4tm4n$ mkfifo audiodump.pcm
MacBook:~ B4tm4n$
MacBook:~ B4tm4n$ echo $?
0
MacBook:~ B4tm4n$





Thanks for the reply talen9. Anyway I got it to work by splitting the two commands up and executing them 1 at a time. Thanks mic64.

talen9
5th December 2007, 13:01
Hmm strange anyway ... seems like the two commands weren't executed sequentially when run from inside the script, causing mplayer trying to open the FIFO before it was actually created :confused:

Anyway, I'm glad you got it working! ;)