18#include <wx/listbox.h>
19#include <wx/combobox.h>
20#include <wx/stattext.h>
28#if wxUSE_ACCESSIBILITY
84#if LIBAVCODEC_VERSION_MAJOR < 58
120#if LIBAVCODEC_VERSION_MAJOR < 58
169#if LIBAVCODEC_VERSION_MAJOR < 58
277 #if LIBAVCODEC_VERSION_MAJOR < 58
327#if LIBAVCODEC_VERSION_MAJOR < 58
351 {
wxT(
"1") ,
XO(
"LC")},
352 {
wxT(
"0") ,
XO(
"Main")},
354 {
wxT(
"3") ,
XO(
"LTP")},
362 {
FMT_M4A,
wxT(
"M4A"),
wxT(
"m4a"),
wxT(
"ipod"), 48,
AV_CANMETA,
true,
XO(
"M4A (AAC) Files (FFmpeg)"),
AUDACITY_AV_CODEC_ID_AAC,
true},
363 {
FMT_AC3,
wxT(
"AC3"),
wxT(
"ac3"),
wxT(
"ac3"), 7,
AV_VERSION_INT(0,0,0),
false,
XO(
"AC3 Files (FFmpeg)"),
AUDACITY_AV_CODEC_ID_AC3,
true},
364 {
FMT_AMRNB,
wxT(
"AMRNB"),
wxT(
"amr"),
wxT(
"amr"), 1,
AV_VERSION_INT(0,0,0),
false,
XO(
"AMR (narrow band) Files (FFmpeg)"),
AUDACITY_AV_CODEC_ID_AMR_NB,
true},
365 #ifdef SHOW_FFMPEG_OPUS_EXPORT
366 {FMT_OPUS,
wxT(
"OPUS"),
wxT(
"opus"),
wxT(
"opus"), 255,
AV_CANMETA,
true,
XO(
"Opus (OggOpus) Files (FFmpeg)"),
AUDACITY_AV_CODEC_ID_OPUS,
true},
368 {
FMT_WMA2,
wxT(
"WMA"),
wxT(
"wma"),
wxT(
"asf"), 2,
AV_VERSION_INT(52,53,0),
false,
XO(
"WMA (version 2) Files (FFmpeg)"),
AUDACITY_AV_CODEC_ID_WMAV2,
true},
479 XO(
"Configure custom FFmpeg options"))
486 mPresets = std::make_unique<FFmpegPresets>();
503 if (codec !=
nullptr)
518 for (
auto ofmt :
mFFmpeg->GetOutputFormats())
524 mFormatNames.push_back(wxString::FromUTF8(ofmt->GetName()));
540 std::unique_ptr<AVCodecWrapper> codec;
541 for (
auto codec :
mFFmpeg->GetCodecs())
544 if (codec->IsAudio() &&
mFFmpeg->av_codec_is_encoder(codec->GetWrappedValue()))
550 mCodecNames.push_back(wxString::FromUTF8(codec->GetName()));
563 IntSetting PredictionOrderSetting{ L
"/FileFormats/FFmpegPredOrderMethod",
566 S.StartVerticalLay(1);
567 S.StartMultiColumn(1, wxEXPAND);
570 S.StartMultiColumn(7, wxEXPAND);
574 S.Id(FELoadPresetID).AddButton(
XXO(
"Load Preset"));
575 S.Id(FESavePresetID).AddButton(
XXO(
"Save Preset"));
576 S.Id(FEDeletePresetID).AddButton(
XXO(
"Delete Preset"));
577 S.Id(FEImportPresetsID).AddButton(
XXO(
"Import Presets"));
578 S.Id(FEExportPresetsID).AddButton(
XXO(
"Export Presets"));
581 S.StartMultiColumn(4, wxALIGN_LEFT);
585 S.Id(FEFormatLabelID).AddFixedText(
XO(
"Format:"));
586 mFormatName =
S.Id(FEFormatNameID).AddVariableText( {} );
588 S.Id(FECodecLabelID).AddFixedText(
XO(
"Codec:"));
589 mCodecName =
S.Id(FECodecNameID).AddVariableText( {} );
592 S.AddVariableText(
XO(
593"Not all formats and codecs are compatible. Nor are all option combinations compatible with all codecs."),
595 S.StartMultiColumn(2, wxEXPAND);
597 S.StartMultiColumn(2, wxEXPAND);
600 S.Id(FEAllFormatsID).AddButton(
XXO(
"Show All Formats"));
601 S.Id(FEAllCodecsID).AddButton(
XXO(
"Show All Codecs"));
608#if wxUSE_ACCESSIBILITY
615 S.StartVerticalLay();
619 S.StartStatic(
XO(
"General Options"), 0);
621 S.StartMultiColumn(8, wxEXPAND);
624 .ToolTip(
XO(
"ISO 639 3-letter language code\nOptional\nempty - automatic"))
625 .TieTextBox(
XXO(
"Language:"), {
wxT(
"/FileFormats/FFmpegLanguage"), wxEmptyString}, 9);
628 S.AddVariableText(
XO(
"Bit Reservoir"));
629 S.Id(FEBitReservoirID).TieCheckBox( {}, {
wxT(
"/FileFormats/FFmpegBitReservoir"),
true});
632 S.AddVariableText(
XO(
"VBL"));
633 S.Id(FEVariableBlockLenID).TieCheckBox( {}, {
wxT(
"/FileFormats/FFmpegVariableBlockLen"),
true});
636 S.StartMultiColumn(4, wxALIGN_LEFT);
640 .ToolTip(
XO(
"Codec tag (FOURCC)\nOptional\nempty - automatic"))
641 .TieTextBox(
XXO(
"Tag:"), {
wxT(
"/FileFormats/FFmpegTag"), wxEmptyString}, 4);
644 .ToolTip(
XO(
"Bit Rate (bits/second) - influences the resulting file size and quality\nSome codecs may only accept specific values (128k, 192k, 256k etc)\n0 - automatic\nRecommended - 192000"))
645 .TieSpinCtrl(
XXO(
"Bit Rate:"), {
wxT(
"/FileFormats/FFmpegBitRate"), 0}, 1000000, 0);
648 .ToolTip(
XO(
"Overall quality, used differently by different codecs\nRequired for vorbis\n0 - automatic\n-1 - off (use bitrate instead)"))
649 .TieSpinCtrl(
XXO(
"Quality:"), {
wxT(
"/FileFormats/FFmpegQuality"), 0}, 500, -1);
652 .ToolTip(
XO(
"Sample rate (Hz)\n0 - don't change sample rate"))
653 .TieSpinCtrl(
XXO(
"Sample Rate:"), {
wxT(
"/FileFormats/FFmpegSampleRate"), 0}, 200000, 0);
656 .ToolTip(
XO(
"Audio cutoff bandwidth (Hz)\nOptional\n0 - automatic"))
657 .TieSpinCtrl(
XXO(
"Cutoff:"), {
wxT(
"/FileFormats/FFmpegCutOff"), 0}, 10000000, 0);
661 .ToolTip(
XO(
"AAC Profile\nLow Complexity - default\nMost players won't play anything other than LC"))
662 .MinSize( { 100, -1 } )
668 S.StartStatic(
XO(
"FLAC options"),0);
670 S.StartMultiColumn(4, wxALIGN_LEFT);
673 .ToolTip(
XO(
"Compression level\nRequired for FLAC\n-1 - automatic\nmin - 0 (fast encoding, large output file)\nmax - 10 (slow encoding, small output file)"))
674 .Id(FECompLevelID).TieSpinCtrl(
XXO(
"Compression:"), {
wxT(
"/FileFormats/FFmpegCompLevel"), 0}, 10, -1);
677 .ToolTip(
XO(
"Frame size\nOptional\n0 - default\nmin - 16\nmax - 65535"))
678 .TieSpinCtrl(
XXO(
"Frame:"), {
wxT(
"/FileFormats/FFmpegFrameSize"), 0}, 65535, 0);
681 .ToolTip(
XO(
"LPC coefficients precision\nOptional\n0 - default\nmin - 1\nmax - 15"))
682 .TieSpinCtrl(
XXO(
"LPC"), {
wxT(
"/FileFormats/FFmpegLPCCoefPrec"), 0}, 15, 0);
685 .ToolTip(
XO(
"Prediction Order Method\nEstimate - fastest, lower compression\nLog search - slowest, best compression\nFull search - default"))
686 .MinSize( { 100, -1 } )
689 PredictionOrderSetting,
694 .ToolTip(
XO(
"Minimal prediction order\nOptional\n-1 - default\nmin - 0\nmax - 32 (with LPC) or 4 (without LPC)"))
695 .TieSpinCtrl(
XXO(
"Min. PdO"), {
wxT(
"/FileFormats/FFmpegMinPredOrder"), -1}, 32, -1);
698 .ToolTip(
XO(
"Maximal prediction order\nOptional\n-1 - default\nmin - 0\nmax - 32 (with LPC) or 4 (without LPC)"))
699 .TieSpinCtrl(
XXO(
"Max. PdO"), {
wxT(
"/FileFormats/FFmpegMaxPredOrder"), -1}, 32, -1);
701 S.Id(FEMinPartOrderID)
702 .ToolTip(
XO(
"Minimal partition order\nOptional\n-1 - default\nmin - 0\nmax - 8"))
703 .TieSpinCtrl(
XXO(
"Min. PtO"), {
wxT(
"/FileFormats/FFmpegMinPartOrder"), -1}, 8, -1);
705 S.Id(FEMaxPartOrderID)
706 .ToolTip(
XO(
"Maximal partition order\nOptional\n-1 - default\nmin - 0\nmax - 8"))
707 .TieSpinCtrl(
XXO(
"Max. PtO"), {
wxT(
"/FileFormats/FFmpegMaxPartOrder"), -1}, 8, -1);
711 S.AddVariableText(
XO(
"Use LPC"));
713 S.Id(FEUseLPCID).TieCheckBox( {}, {
wxT(
"/FileFormats/FFmpegUseLPC"),
true});
718 S.StartStatic(
XO(
"MPEG container options"),0);
720 S.StartMultiColumn(4, wxALIGN_LEFT);
723 .ToolTip(
XO(
"Maximum bit rate of the multiplexed stream\nOptional\n0 - default"))
727 .TieSpinCtrl(
XXO(
"Mux Rate:"), {
wxT(
"/FileFormats/FFmpegMuxRate"), 0}, 10000000, 0);
732 .ToolTip(
XO(
"Packet size\nOptional\n0 - default"))
735 .TieSpinCtrl(
XXO(
"Packet Size:"), {
wxT(
"/FileFormats/FFmpegPacketSize"), 0}, 10000000, 0);
753 SetMinSize(GetSize());
764 wxArrayInt selections;
769 wxString selfmt =
mFormatList->GetString(selections[0]);
773 if (nFormat == wxNOT_FOUND)
return;
785 wxArrayInt selections;
786 int n =
mCodecList->GetSelections(selections);
790 wxString selcdc =
mCodecList->GetString(selections[0]);
794 if (nCodec == wxNOT_FOUND)
return;
805 const auto ffmpegId =
mFFmpeg->GetAVCodecID(
id);
832 if (codec != NULL && codec->IsAudio() &&
mFFmpeg->av_codec_is_encoder(codec->GetWrappedValue()))
835 if ((ffmpegId >= 0) && codec->GetId() == ffmpegId)
846 std::unique_ptr<AVCodecWrapper> codec;
847 for (
auto codec :
mFFmpeg->GetCodecs())
849 if (codec->IsAudio() &&
mFFmpeg->av_codec_is_encoder(codec->GetWrappedValue()))
856 .contains( wxString::FromUTF8(codec->GetName()) ) )
858 if ((ffmpegId >= 0) && codec->GetId() == ffmpegId)
871 wxCharBuffer buf =
str.ToUTF8();
872 auto format =
mFFmpeg->GuessOutputFormat(buf,
nullptr,
nullptr);
876 auto codec =
mFFmpeg->CreateEncoder(
format->GetAudioCodec());
879 codec !=
nullptr && codec->IsAudio() &&
mFFmpeg->av_codec_is_encoder(codec->GetWrappedValue()))
881 if ((ffmpegId >= 0) && codec->GetId() == ffmpegId)
905 wxArrayString FromList;
914 auto tofmt =
mFFmpeg->GuessOutputFormat(
921 wxString::FromUTF8(tofmt->GetLongName())));
941 for (
auto ofmt :
mFFmpeg->GetOutputFormats())
943 if (ofmt->GetAudioCodec() ==
mFFmpeg->GetAVCodecID(
id))
945 wxString ofmtname = wxString::FromUTF8(ofmt->GetName());
947 for (
unsigned int i = 0; i < FromList.size(); i++)
949 if (ofmtname == FromList[i])
957 if ((selfmt != NULL) &&
958 (*selfmt == wxString::FromUTF8(ofmt->GetName())))
965 wxString::FromUTF8(ofmt->GetLongName())));
978 wxComboBox *
preset =
dynamic_cast<wxComboBox*
>(FindWindowById(FEPresetID,
this));
979 wxString presetname =
preset->GetValue();
980 if (presetname.empty())
986 auto query =
XO(
"Delete preset '%s'?").Format( presetname );
989 XO(
"Confirm Deletion"),
990 wxYES_NO | wxCENTRE);
991 if (action == wxNO)
return;
994 long index =
preset->FindString(presetname);
995 preset->SetValue(wxEmptyString);
1005{
const bool kCheckForOverwrite =
true;
1012 wxComboBox *
preset =
dynamic_cast<wxComboBox*
>(FindWindowById(FEPresetID,
this));
1019 if( bCheckForOverwrite && !
mPresets->OverwriteIsOk(
name))
1038 wxComboBox *
preset =
dynamic_cast<wxComboBox*
>(FindWindowById(FEPresetID,
this));
1039 wxString presetname =
preset->GetValue();
1051 mPresets->LoadPreset(
this,presetname);
1070 XO(
"Select xml file with presets to import"),
1075 if (dlg.
ShowModal() == wxID_CANCEL)
return;
1087 const bool kCheckForOverwrite =
true;
1093 wxArrayString presets;
1095 if( presets.Count() < 1)
1103 XO(
"Select xml file to export presets into"),
1107 wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
1108 if (dlg.
ShowModal() == wxID_CANCEL)
return;
1142 wxString *selcdc =
nullptr;
1143 wxString* selcdclong =
nullptr;
1147 if (selcdc ==
nullptr)
1150 auto cdc =
mFFmpeg->CreateEncoder(selcdc->ToUTF8());
1155 wxString* selfmt =
nullptr;
1156 wxString* selfmtlong =
nullptr;
1160 if (selfmt ==
nullptr)
1166 bool bFound =
false;
1191 XO(
"Format %s is not compatible with codec %s.")
1192 .
Format( *selfmt, *selcdc ),
1194 XO(
"Incompatible format and codec"));
1206 if (
apptable[i].control != handled)
1222 else if (selfmt != NULL &&
1227 wxWindow *item = FindWindowById(
apptable[i].control,
this);
1228 if (item != NULL) item->Enable(
apptable[i].enable);
1236 wxString *selfmt = NULL;
1237 wxString *selfmtlong = NULL;
1244 wxString *selcdc = NULL;
1245 wxString *selcdclong = NULL;
1248 auto fmt =
mFFmpeg->GuessOutputFormat(selfmt->ToUTF8(),NULL,NULL);
1252 mFormatName->SetLabel(wxString(
_(
"Failed to guess format")));
1259 if (selcdc !=
nullptr)
1261 auto cdc =
mFFmpeg->CreateEncoder(selcdc->ToUTF8());
1265 selcdcid =
mFFmpeg->GetAudacityCodecID(cdc->GetId());
1271 if (newselcdc >= 0)
mCodecList->Select(newselcdc);
1273 std::unique_ptr<AVCodecWrapper> cdc;
1275 if (selcdc !=
nullptr)
1276 cdc =
mFFmpeg->CreateEncoder(selcdc->ToUTF8());
1286 wxString *selcdc =
nullptr;
1287 wxString* selcdclong =
nullptr;
1291 if (selcdc ==
nullptr)
1296 wxString* selfmt =
nullptr;
1297 wxString* selfmtlong =
nullptr;
1301 auto cdc =
mFFmpeg->CreateEncoder(selcdc->ToUTF8());
1306 mCodecName->SetLabel(wxString(
_(
"Failed to find the codec")));
1310 mCodecName->SetLabel(wxString::Format(
wxT(
"[%d] %s"), (
int)
mFFmpeg->GetAudacityCodecID(cdc->GetId()).value, *selcdclong));
1312 if (selfmt !=
nullptr)
1314 auto fmt =
mFFmpeg->GuessOutputFormat(selfmt->ToUTF8(),
nullptr,
nullptr);
1318 selfmtlong =
nullptr;
1323 mFFmpeg->GetAudacityCodecID(cdc->GetId()), selfmt);
@ AUDACITY_AV_CODEC_ID_GSM_MS
@ AUDACITY_AV_CODEC_ID_IMC
@ AUDACITY_AV_CODEC_ID_QCELP
@ AUDACITY_AV_CODEC_ID_PCM_S16BE
@ AUDACITY_AV_CODEC_ID_ADPCM_G726
@ AUDACITY_AV_CODEC_ID_OPUS
@ AUDACITY_AV_CODEC_ID_ADPCM_IMA_QT
@ AUDACITY_AV_CODEC_ID_QDM2
@ AUDACITY_AV_CODEC_ID_PCM_S24LE
@ AUDACITY_AV_CODEC_ID_ADPCM_YAMAHA
@ AUDACITY_AV_CODEC_ID_AC3
@ AUDACITY_AV_CODEC_ID_MACE3
@ AUDACITY_AV_CODEC_ID_PCM_MULAW
@ AUDACITY_AV_CODEC_ID_PCM_S8
@ AUDACITY_AV_CODEC_ID_VORBIS
@ AUDACITY_AV_CODEC_ID_DVAUDIO
@ AUDACITY_AV_CODEC_ID_PCM_S32BE
@ AUDACITY_AV_CODEC_ID_DTS
@ AUDACITY_AV_CODEC_ID_ALAC
@ AUDACITY_AV_CODEC_ID_PCM_S16LE
@ AUDACITY_AV_CODEC_ID_PCM_S32LE
@ AUDACITY_AV_CODEC_ID_FLAC
@ AUDACITY_AV_CODEC_ID_PCM_ALAW
@ AUDACITY_AV_CODEC_ID_WMAV1
@ AUDACITY_AV_CODEC_ID_NONE
@ AUDACITY_AV_CODEC_ID_ADPCM_SWF
@ AUDACITY_AV_CODEC_ID_VOXWARE
@ AUDACITY_AV_CODEC_ID_NELLYMOSER
@ AUDACITY_AV_CODEC_ID_GSM
@ AUDACITY_AV_CODEC_ID_PCM_U8
@ AUDACITY_AV_CODEC_ID_ROQ_DPCM
@ AUDACITY_AV_CODEC_ID_TRUESPEECH
@ AUDACITY_AV_CODEC_ID_MP2
@ AUDACITY_AV_CODEC_ID_WMAPRO
@ AUDACITY_AV_CODEC_ID_WMAV2
@ AUDACITY_AV_CODEC_ID_AMR_NB
@ AUDACITY_AV_CODEC_ID_MP3
@ AUDACITY_AV_CODEC_ID_PCM_S24BE
@ AUDACITY_AV_CODEC_ID_ATRAC3
@ AUDACITY_AV_CODEC_ID_ADPCM_MS
@ AUDACITY_AV_CODEC_ID_AMR_WB
@ AUDACITY_AV_CODEC_ID_AAC
@ AUDACITY_AV_CODEC_ID_ADPCM_IMA_WAV
@ AUDACITY_AV_CODEC_ID_MACE6
@ AUDACITY_AV_CODEC_ID_WMAVOICE
@ AUDACITY_AV_CODEC_ID_ADPCM_CT
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
static const FileNames::FileTypes & FileTypes()
ChoiceSetting AACProfiles
AAC profiles.
#define AV_VERSION_INT(a, b, c)
XXO("&Cut/Copy/Paste Toolbar")
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
audacity::BasicSettings * gPrefs
std::vector< TranslatableString > TranslatableStrings
virtual AVCodecIDFwd GetId() const noexcept=0
Custom FFmpeg export dialog.
void OnExportPresets(wxCommandEvent &event)
void OnSavePreset(wxCommandEvent &event)
void OnImportPresets(wxCommandEvent &event)
void FindSelectedCodec(wxString **name, wxString **longname)
Finds the codec currently selected and returns its name and description.
wxArrayStringEx mCodecNames
wxComboBox * mPresetCombo
void OnDeletePreset(wxCommandEvent &event)
wxArrayString mShownFormatLongNames
void FetchCodecList()
Retrieves codec list from libavcodec.
static CompatibilityEntry CompatibilityList[]
std::unique_ptr< FFmpegPresets > mPresets
int FetchCompatibleFormatList(AudacityAVCodecID id, wxString *selfmt)
void OnCodecList(wxCommandEvent &event)
void PopulateOrExchange(ShuttleGui &S)
void FindSelectedFormat(wxString **name, wxString **longname)
Finds the format currently selected and returns its name and description.
void OnLoadPreset(wxCommandEvent &event)
wxArrayStringEx mFormatNames
wxArrayString mShownCodecLongNames
wxArrayString mShownCodecNames
int FetchCompatibleCodecList(const wxChar *fmt, AudacityAVCodecID id)
wxStaticText * mCodecName
wxArrayString mCodecLongNames
void OnFormatList(wxCommandEvent &event)
void OnAllFormats(wxCommandEvent &event)
wxStaticText * mFormatName
void OnOK(wxCommandEvent &event)
ExportFFmpegOptions(wxWindow *parent)
void OnAllCodecs(wxCommandEvent &event)
bool SavePreset(bool bCheckForOverwrite)
void FetchFormatList()
Retrieves format list from libavformat.
static ExposedFormat fmts[]
List of export types.
static ApplicableFor apptable[]
bool ReportIfBadCombination()
wxArrayString mShownFormatNames
void OnGetURL(wxCommandEvent &event)
wxArrayStringEx mPresetNames
void EnableDisableControls(AVCodecWrapper *cdc, wxString *selfmt)
std::shared_ptr< FFmpegFunctions > mFFmpeg
wxArrayString mFormatLongNames
virtual wxString GetPath() const
FILES_API const FileType XMLFiles
std::vector< FileType > FileTypes
FILES_API const FileType AllFiles
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Specialization of Setting for int.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
const TranslatableStrings PredictionOrderMethodNames
Prediction order method - names.
std::string ToUTF8(const std::wstring &wstr)
Entry for the Applicability table.
Describes format-codec compatibility.
const wxChar * fmt
format, recognizable by guess_format()
AudacityAVCodecID codec
codec ID
static std::shared_ptr< FFmpegFunctions > Load(bool fromUserPathOnly=false)