MCPcopy Create free account
hub / github.com/audacity/audacity / InitCodecs

Method InitCodecs

modules/import-export/mod-ffmpeg/ExportFFmpeg.cpp:980–1304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978}
979
980bool FFmpegExporter::InitCodecs(int sampleRate,
981 const ExportProcessor::Parameters& parameters)
982{
983 std::unique_ptr<AVCodecWrapper> codec;
984
985 AVDictionaryWrapper options(*mFFmpeg);
986
987 // Get the sample rate from the passed settings if we haven't set it before.
988 // Doing this only when not set allows us to carry the sample rate from one
989 // iteration of ExportMultiple to the next. This prevents multiple resampling
990 // dialogs in the event the codec can't support the specified rate.
991 if (!mSampleRate)
992 {
993 //TODO: Does not work with export multiple any more...
994 mSampleRate = sampleRate;
995 }
996
997 // Configure the audio stream's codec context.
998
999 const auto codecID = ExportFFmpegOptions::fmts[mSubFormat].codecid;
1000
1001 mEncAudioCodecCtx->SetGlobalQuality(-99999); //quality mode is off by default;
1002
1003 // Each export type has its own settings
1004 switch (mSubFormat)
1005 {
1006 case FMT_M4A:
1007 {
1008 int q = ExportPluginHelpers::GetParameterValue(parameters, AACOptionIDQuality, -99999);
1009
1010 q = wxClip( q, 98 * mChannels, 160 * mChannels );
1011 // Set bit rate to between 98 kbps and 320 kbps (if two channels)
1012 mEncAudioCodecCtx->SetBitRate(q * 1000);
1013 mEncAudioCodecCtx->SetProfile(AUDACITY_FF_PROFILE_AAC_LOW);
1014 mEncAudioCodecCtx->SetCutoff(0);
1015
1016 break;
1017 }
1018 case FMT_AC3:
1019 mEncAudioCodecCtx->SetBitRate(ExportPluginHelpers::GetParameterValue(parameters, AC3OptionIDBitRate, 192000));
1020 if (!CheckSampleRate(
1021 mSampleRate, iAC3SampleRates[0],
1022 iAC3SampleRates[2],
1023 &iAC3SampleRates[0]))
1024 {
1025 mSampleRate = AskResample(
1026 mEncAudioCodecCtx->GetBitRate(), mSampleRate,
1027 iAC3SampleRates[0],
1028 iAC3SampleRates[2],
1029 &iAC3SampleRates[0]);
1030 }
1031 break;
1032 case FMT_AMRNB:
1033 mSampleRate = 8000;
1034 mEncAudioCodecCtx->SetBitRate(ExportPluginHelpers::GetParameterValue(parameters, AMRNBOptionIDBitRate, 12200));
1035 break;
1036#ifdef SHOW_FFMPEG_OPUS_EXPORT
1037 case FMT_OPUS:

Callers

nothing calls this directly

Calls 15

GetParameterValueFunction · 0.85
VerbatimFunction · 0.85
GetMetadataMethod · 0.80
SetMetadataMethod · 0.80
SetCodecTagFourCCMethod · 0.80
CreateEncoderMethod · 0.80
TranslationMethod · 0.80
GetIdMethod · 0.80
GetOutputFormatMethod · 0.80
SetMethod · 0.45
GetSampleRateMethod · 0.45

Tested by

no test coverage detected