| 978 | } |
| 979 | |
| 980 | bool 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: |
nothing calls this directly
no test coverage detected