我有一个文件,其中包含大约四万个整数的列表,这些整数以空格分隔,每个整数的值都在 0 到 255 之间。这里是这个文件:
https://github.com/johnlai2004/sound-project/blob/master/integers.txt https://github.com/johnlai2004/sound-project/blob/master/integers.txt
如果您将扬声器连接到 ESP32 分线板,然后通过数模转换器以 24kHz 的频率运行此整数列表,您将听到这句话:“这不是您错过的帖子。”
我想知道的是如何使用 FFMPEG 将这个整数列表转换为其他计算机可以播放以听到相同短语的声音文件?我尝试了这个命令:
ffmpeg -f u8 -ac 1 -ar 24000 -i integers.txt -y audio.wav
But my audio.wav
听起来就像白噪音。我尝试了一些其他值-f
并为-ar
,但我听到的只是不同频率的白噪声,也许还有一些额外的嗡嗡声。
是否可以使用 ffmpeg 将我的整数列表转换为音频文件以供其他计算机播放?如果是这样,执行此操作的正确 ffmpeg 命令是什么?
其他注意事项
如果有帮助的话,如果我想听音频,这是我上传到 ESP32 的草图文件:
https://github.com/johnlai2004/sound-project/blob/master/play-audio.ino https://github.com/johnlai2004/sound-project/blob/master/play-audio.ino
简而言之,该文件如下所示:
#define speakerPin 25 //The pins to output audio on. (9,10 on UNO,Nano)
#define bufferTotal 1347
#define buffSize 32
byte buffer[bufferTotal][buffSize];
int buffItemN = 0;
int bufferN = 0;
hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
void IRAM_ATTR onTimer() {
portENTER_CRITICAL_ISR(&timerMux);
byte v = buffer[bufferN][buffItemN];
dacWrite(speakerPin,v);
buffItemN++;
if(buffItemN >= buffSize){ //If the buffer is empty, do the following
buffItemN = 0; //Reset the sample count
bufferN++;
if(bufferN >= bufferTotal)
bufferN = 0;
}
portEXIT_CRITICAL_ISR(&timerMux);
}
void setup() {
/* buffer records */
buffer[0][0]=88; // I split the long list of integers and load it into a 2D array
buffer[0][1]=88;
buffer[0][2]=86;
buffer[0][3]=85;
//etc....
buffer[1346][28]=94;
buffer[1346][29]=92;
buffer[1346][30]=92;
buffer[1346][31]=95;
/* end buffer records */
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 41, true);
timerAlarmEnable(timer);
}
void loop() {
}
The buffer...
是在中找到的整数列表integers.txt
file.