afconvert
不会写。mp3
文件。即使它在帮助中以格式列出:
MacBook-Pro:local user$ afconvert -hf
Audio file and data formats:
'3gpp' = 3GP Audio (.3gp)
data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aach' 'aacl'
'aacp' 'samr'
'3gp2' = 3GPP-2 Audio (.3g2)
data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aach' 'aacl'
'aacp' 'samr'
'adts' = AAC ADTS (.aac, .adts)
data_formats: 'aac ' 'aach' 'aacp'
'ac-3' = AC3 (.ac3)
data_formats: 'ac-3'
'AIFC' = AIFC (.aifc, .aiff, .aif)
data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 UI8 'ulaw'
'alaw' 'MAC3' 'MAC6' 'ima4' 'QDMC' 'QDM2'
'Qclp' 'agsm'
'AIFF' = AIFF (.aiff, .aif)
data_formats: I8 BEI16 BEI24 BEI32
'amrf' = AMR (.amr)
data_formats: 'samr'
'm4af' = Apple MPEG-4 Audio (.m4a, .m4r)
data_formats: 'aac ' 'aace' 'aacf' 'aach' 'aacl' 'aacp'
'alac' 'paac'
'm4bf' = Apple MPEG-4 AudioBooks (.m4b)
data_formats: 'aac ' 'aace' 'aacf' 'aach' 'aacl' 'aacp'
'paac'
'caff' = CAF (.caf)
data_formats: '.mp1' '.mp2' '.mp3' 'QDM2' 'QDMC' 'Qclp'
'Qclq' 'aac ' 'aace' 'aacf' 'aach' 'aacl'
'aacp' 'alac' 'alaw' 'dvi8' 'ilbc' 'ima4'
I8 BEI16 BEI24 BEI32 BEF32 BEF64 LEI16 LEI24
LEI32 LEF32 LEF64 'ms\x00\x02' 'ms\x00\x11'
'ms\x001' 'paac' 'samr' 'ulaw'
'MPG1' = MPEG Layer 1 (.mp1, .mpeg, .mpa)
data_formats: '.mp1'
'MPG2' = MPEG Layer 2 (.mp2, .mpeg, .mpa)
data_formats: '.mp2'
'MPG3' = MPEG Layer 3 (.mp3, .mpeg, .mpa)
data_formats: '.mp3'
如果您尝试使用它:
/usr/bin/afconvert -d '.mp3' -f MPG3 mysong.MP4 -o mysong.mp3
然后发生错误:
Error: ExtAudioFileSetProperty ('cfmt') failed ('fmt?')
如afconvert MPG3所述?
“ Core Audio可以读取但不能写入MP3文件...”
我最终使用zpletan的答案并安装了ffmpeg
brew install ffmpeg
和以下脚本,它们与我要转换的.MP4文件放在同一目录中。它也适用于带空格的文件:
#!/bin/sh -x
for f in *.MP4; do
/usr/local/Cellar/ffmpeg/2.5.4/bin/ffmpeg -i "$f" "$f.mp3"
# /usr/bin/afconvert -d '.mp3' -f MPG3 "$f" -o "$f.mp3"
echo "$f converted"
done