9#include <boost/program_options.hpp>
11void TestAudio(
const boost::program_options::variables_map &vm,
12 const std::map<std::string, std::string> &ffmpegOptions) {
13 auto inputFormat = vm[
"inputFormat"].as<std::string>();
14 auto deviceName = vm[
"deviceName"].as<std::string>();
15 int recordTime = vm[
"testAudio"].as<
int>();
16 int loopRecordTime = vm[
"audioLoopTime"].as<
int>();
20 std::vector<std::unique_ptr<FFmpegFrameSink>> sinks;
21 AVChannelLayout channel_layout = AV_CHANNEL_LAYOUT_MONO;
22 sinks.push_back(std::make_unique<AudioFrameSink>(
23 channel_layout, AV_SAMPLE_FMT_S16, 48000, loopRecordTime != -1,
24 48000 * (loopRecordTime != -1 ? loopRecordTime : recordTime)));
25 auto audioSink = sinks[0].get();
28 FFmpegRecorder recorder(inputFormat, deviceName, ffmpegOptions, sinks);
29 std::this_thread::sleep_for(std::chrono::seconds(recordTime));
32 std::vector<uint8_t> data;
33 audioSink->getData(data);
35 std::cout <<
"Enter the output filename:\n";
36 std::string audioFilename;
37 std::getline(std::cin, audioFilename);
39 std::ofstream outfile(audioFilename, std::ios::out | std::ios::binary);
40 outfile.write(
reinterpret_cast<char *
>(data.data()),
41 static_cast<std::streamsize
>(data.size()));
void TestAudio(const boost::program_options::variables_map &vm, const std::map< std::string, std::string > &ffmpegOptions)
Definition: TestAudio.h:11
Definition: FFmpegRecorder.h:12