Mac OS 下使用 afconvert 命令,处理音频格式转换
https://www.jianshu.com/p/06843a0b02e2
在上一篇《Mac OS 下使用 you-get 下载音悦台 MV 、网易云音乐等》给大家介绍了如何下载MV、音乐等资源,但是出现了一些不常见的音频格式,导致在有些播放器上无法解码播放,所以在这篇文章中教大家一个利用 Apple 自带的工具 afconvert
做音频格式转换,当然如果有格式工厂等格式转换软件的话就没必要使用这种方法了,不过学习倒还是可以的,毕竟自己动手,丰衣足食嘛,哈哈哈😆....
coverImage
afconvert 介绍
afconvert
是 Apple 提供的一个音频格式转换工具。
- 语法
afconvert [option...] input_file [output_file]
Options may appear before or after the direct arguments. If output_file
is not specified, a name is generated programmatically and the file
is written into the same directory as input_file.
afconvert input_file [-o output_file [option...]]...
Output file options apply to the previous output_file.
Other options may appear anywhere.
- 一般选项
{ -d | --data } data_format[@sample_rate][/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 (see -hf)
format_flags: hex digits, e.g. '80'
Frames per packet can be specified for some encoders, e.g.: samr#12
A format of "0" specifies the same format as the source file,
with packets copied exactly.
A format of "N" specifies the destination format should be the
native format of the lossless encoded source file (alac, FLAC only)
{ -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 } total_bit_rate_bps
e.g. 256000 will give you roughly:
for stereo source: 128000 bits per channel
for 5.1 source: 51000 bits per channel
(the .1 channel consumes few bits and can be discounted in the
total bit rate calculation)
{ -q | --quality } codec_quality
codec_quality: 0-127
{ -r | --src-quality } src_quality
src_quality (sample rate converter quality): 0-127 (default is 127)
{ --src-complexity } src_complexity
src_complexity (sample rate converter complexity): line, norm, bats
{ -s | --strategy } strategy
bitrate allocation strategy for encoding an audio track
0 for CBR, 1 for ABR, 2 for VBR_constrained, 3 for VBR
--prime-method method
decode priming method (see AudioConverter.h)
--prime-override samples_prime samples_remain
can be used to override the priming information stored in the source
file to the specified values. If -1 is specified for either, the value
in the file is used.
--no-filler
don't page-align audio data in the output file
--soundcheck-generate
analyze audio, add SoundCheck data to the output file
--media-kind "media kind string"
media kinds are: "Audio Ad", "Video Ad"
--anchor-loudness
set a single precision floating point value to
indicate the anchor loudness of the content in dB
--generate-hash
generate an SHA-1 hash of the input audio data and add it to the output file.
--codec-manuf codec_manuf
specify the codec with the specified 4-character component manufacturer code
--dither algorithm
algorithm: 1-2
--mix
enable channel downmixing
{ -u | --userproperty } property value
set an arbitrary AudioConverter property to a given value
property is a four-character code; value can be a signed
32-bit integer or a single precision floating point value.
e.g