From 72276c20c211b0b2d77007861d2da348cdc9a5ec Mon Sep 17 00:00:00 2001 From: onlyet <19988547+onlyet@users.noreply.github.com> Date: Tue, 15 Aug 2023 01:00:17 +0800 Subject: [PATCH] Record speaker with resample filter in Ubuntu --- RecordCore/src/FFmpegHelper.cpp | 4 ++-- RecordCore/src/filter.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/RecordCore/src/FFmpegHelper.cpp b/RecordCore/src/FFmpegHelper.cpp index 0beedd2..fadc4d0 100644 --- a/RecordCore/src/FFmpegHelper.cpp +++ b/RecordCore/src/FFmpegHelper.cpp @@ -159,10 +159,10 @@ std::string FFmpegHelper::getAudioDevice(AudioCaptureDevice type) { ::CoUninitialize(); #elif __linux__ QString dev; - if (AudioCaptureDevice_Speaker == type) { + if (AudioCaptureDevice::Speaker == type) { // ret = "alsa_output.pci-0000_02_02.0.analog-stereo.monitor"; dev = "alsa_output"; - } else if (AudioCaptureDevice_Microphone == type) { + } else if (AudioCaptureDevice::Microphone == type) { // ret = "alsa_input.pci-0000_02_02.0.analog-stereo"; dev = "alsa_input"; } diff --git a/RecordCore/src/filter.cpp b/RecordCore/src/filter.cpp index 93b8abd..7f0b511 100644 --- a/RecordCore/src/filter.cpp +++ b/RecordCore/src/filter.cpp @@ -1,4 +1,7 @@ #include "filter.h" + +#include + #ifdef __cplusplus extern "C" { #endif // __cplusplus @@ -12,12 +15,12 @@ extern "C" { namespace onlyet { void format_pad_arg(char* arg, int size, const FILTER_CTX& ctx) { - sprintf_s(arg, size, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%I64x", + snprintf(arg, size, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%lld", ctx.time_base.num, ctx.time_base.den, ctx.sample_rate, av_get_sample_fmt_name(ctx.sample_fmt), - av_get_default_channel_layout(ctx.nb_channel)); + (long long int)av_get_default_channel_layout(ctx.nb_channel)); } -} // namespace onlyet \ No newline at end of file +} // namespace onlyet