FaceAccess/Record/main.cpp

61 lines
1.8 KiB
C++
Raw Normal View History

2024-06-18 14:27:48 +08:00
#include "FFmpegResample.h"
#include "OpusCodec.h"
#include <fstream>
#include <rkmedia/rkmedia_api.h>
extern int recorder_demo();
extern void rkDemo();
extern int AI_VqeProcess_AO();
extern int AI_VqeProcess_AO1();
extern void AecTest();
extern int opus_test();
int main(int argc, char **argv) {
RK_MPI_SYS_Init();
// std::ifstream ifs("/data/sdcard/test2.pcm", std::ifstream::binary);
// AlsaPcmPlayer player;
// player.open(2, 48000, 2);
// char buffer[2 * 2 * 48 * 60];
// while (ifs.read(buffer, sizeof(buffer))) {
// int size = ifs.gcount();
// player.write((const uint8_t *)buffer, size);
// }
// recorder_demo();
// rkDemo();
// AI_VqeProcess_AO();
// AI_VqeProcess_AO1();
// AecTest();
{
FFmpegResample resample;
resample.initialize(16000, 1, 48000, 2, 20);
std::ifstream ifs("/sdcard/input.pcm", std::ifstream::binary);
std::ofstream ofs("/sdcard/my_48kz.pcm", std::ifstream::binary);
char buffer[16 * 20 * 2];
while (ifs.read(buffer, sizeof(buffer))) {
auto frame = resample.resample((uint8_t *)buffer, sizeof(buffer));
if (frame.data != nullptr) {
ofs.write((char *)frame.data, frame.byteSize);
}
}
}
{
FFmpegResample resample1;
resample1.initialize(48000, 2, 16000, 1, 20);
std::ifstream ifs1("/sdcard/my_48kz.pcm", std::ifstream::binary);
std::ofstream ofs1("/sdcard/my_16kz.pcm", std::ifstream::binary);
char buffer1[48 * 20 * 2 * 2];
while (ifs1.read(buffer1, sizeof(buffer1))) {
auto frame = resample1.resample((uint8_t *)buffer1, sizeof(buffer1));
if (frame.data != nullptr) {
ofs1.write((char *)frame.data, frame.byteSize);
}
}
}
return 0;
}