De acordo com o comentário @ naught101, eu seguiria esse processo para detectar o melhor acodec
:
$ ffmpeg -formats | grep PCM
DE f32be PCM 32-bit floating-point big-endian
DE f32le PCM 32-bit floating-point little-endian
DE f64be PCM 64-bit floating-point big-endian
DE f64le PCM 64-bit floating-point little-endian
DE s16be PCM signed 16-bit big-endian
DE s16le PCM signed 16-bit little-endian
DE s24be PCM signed 24-bit big-endian
DE s24le PCM signed 24-bit little-endian
DE s32be PCM signed 32-bit big-endian
DE s32le PCM signed 32-bit little-endian
DE u16be PCM unsigned 16-bit big-endian
DE u16le PCM unsigned 16-bit little-endian
DE u24be PCM unsigned 24-bit big-endian
DE u24le PCM unsigned 24-bit little-endian
DE u32be PCM unsigned 32-bit big-endian
DE u32le PCM unsigned 32-bit little-endian
Nesse ponto, considere sua plataforma para escolher entre big-endian
, little-endian
, a taxa de bits escolhida:
$ ffmpeg -i sample.mp3
[mp3 @ 0x7fb33180da00] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'sample.mp3':
Metadata:
title : Saturday
artist : Winterwood
album : Love In The Heart
track : 2/15
TPA : 1/1
encoded_by : iTunes 11.0.1
genre : Country & Folk
date : 1997
Duration: 00:04:27.76, start: 0.000000, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
Podemos ver que este arquivo de áudio é um mp3
(isso não é óbvio, apesar da extensão do arquivo de entrada, apenas verificar os bytes) tem uma taxa de bits 128 kb/s
, o codec foi s16p
, amostragem em 44100 Hz
, então escolhemos de acordo:
$ ffmpeg -i sample.mp3 -acodec pcm_s16le -ar 44100 sample.wav
Input #0, mp3, from 'sample.mp3':
Metadata:
title : Saturday
artist : Winterwood
album : Love In The Heart
track : 2/15
TPA : 1/1
encoded_by : iTunes 11.0.1
genre : Country & Folk
date : 1997
Duration: 00:04:27.76, start: 0.000000, bitrate: 128 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
File 'sample.wav' already exists. Overwrite ? [y/N] y
Output #0, wav, to 'sample.wav':
Metadata:
INAM : Saturday
IART : Winterwood
IPRD : Love In The Heart
IPRT : 2/15
TPA : 1/1
ITCH : iTunes 11.0.1
IGNR : Country & Folk
ICRD : 1997
ISFT : Lavf56.4.101
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
Metadata:
encoder : Lavc56.1.100 pcm_s16le
Stream mapping:
Stream #0:0 -> #0:0 (mp3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
size= 46125kB time=00:04:27.75 bitrate=1411.2kbits/s
video:0kB audio:46125kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000457%
Se você estiver no mac, você pode verificar o áudio se ele não tiver white noise
no início / fim (quando o áudio original do mp3 não tiver áudio por alguns ms / seg):
$ afplay sample.wav
e, claro, você pode verificar o bitmap:
$ ffmpeg -i sample.wav
Input #0, wav, from 'sample.wav':
Metadata:
artist : Winterwood
date : 1997
genre : Country & Folk
title : Saturday
album : Love In The Heart
track : 2/15
encoder : Lavf56.4.101
encoded_by : iTunes 11.0.1
Duration: 00:04:27.76, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s