Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
ExportFFmpeg Class Referencefinal

Controlling class for FFmpeg exporting. Creates the options dialog of the appropriate type, adds tags and invokes the export function. More...

Inheritance diagram for ExportFFmpeg:
[legend]
Collaboration diagram for ExportFFmpeg:
[legend]

Public Member Functions

 ExportFFmpeg ()
 
 ~ExportFFmpeg () override
 
std::unique_ptr< ExportOptionsEditorCreateOptionsEditor (int format, ExportOptionsEditor::Listener *listener) const override
 Creates format-dependent options editor, that is used to create a valid set of parameters to be used in exporting. More...
 
int GetFormatCount () const override
 
FormatInfo GetFormatInfo (int index) const override
 Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn't guaranteed to be unique. More...
 
bool CheckFileName (wxFileName &filename, int format=0) const override
 Callback, called from GetFilename. More...
 
std::unique_ptr< ExportProcessorCreateProcessor (int format) const override
 
- Public Member Functions inherited from ExportPlugin
 ExportPlugin ()
 
virtual ~ExportPlugin ()
 
virtual int GetFormatCount () const =0
 
virtual FormatInfo GetFormatInfo (int index) const =0
 Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn't guaranteed to be unique. More...
 
virtual std::unique_ptr< ExportOptionsEditorCreateOptionsEditor (int formatIndex, ExportOptionsEditor::Listener *listener) const =0
 Creates format-dependent options editor, that is used to create a valid set of parameters to be used in exporting. More...
 
virtual std::vector< std::string > GetMimeTypes (int formatIndex) const
 
virtual bool ParseConfig (int formatIndex, const rapidjson::Value &config, ExportProcessor::Parameters &parameters) const
 Attempt to parse configuration JSON object and produce a suitable set of parameters. Configuration is format dependent. More...
 
virtual bool CheckFileName (wxFileName &filename, int format=0) const
 
virtual std::unique_ptr< ExportProcessorCreateProcessor (int format) const =0
 

Private Attributes

std::shared_ptr< FFmpegFunctionsmFFmpeg
 
std::vector< FormatInfomFormatInfos
 

Detailed Description

Controlling class for FFmpeg exporting. Creates the options dialog of the appropriate type, adds tags and invokes the export function.

Definition at line 690 of file ExportFFmpeg.cpp.

Constructor & Destructor Documentation

◆ ExportFFmpeg()

ExportFFmpeg::ExportFFmpeg ( )

Definition at line 738 of file ExportFFmpeg.cpp.

739{
741
742 int avfver = mFFmpeg ? mFFmpeg->AVFormatVersion.GetIntVersion() : 0;
743
744 int newfmt;
745 // Adds export types from the export type list
746 for (newfmt = 0; newfmt < FMT_LAST; newfmt++)
747 {
748 wxString shortname(ExportFFmpegOptions::fmts[newfmt].shortname);
749 // Don't hide export types when there's no av-libs, and don't hide FMT_OTHER
750 if (newfmt < FMT_OTHER && mFFmpeg)
751 {
752 // Format/Codec support is compiled in?
753 auto avoformat = mFFmpeg->GuessOutputFormat(shortname.mb_str(), nullptr, nullptr);
754 auto avcodec = mFFmpeg->CreateEncoder(mFFmpeg->GetAVCodecID(ExportFFmpegOptions::fmts[newfmt].codecid));
755
756 if (avoformat == NULL || avcodec == NULL)
757 {
759 continue;
760 }
761 }
762 FormatInfo formatInfo {};
763 formatInfo.format = ExportFFmpegOptions::fmts[newfmt].name;
764 formatInfo.extensions.push_back(ExportFFmpegOptions::fmts[newfmt].extension);
765 // For some types add other extensions
766 switch(newfmt)
767 {
768 case FMT_M4A:
769 formatInfo.extensions.push_back(wxT("3gp"));
770 formatInfo.extensions.push_back(wxT("m4r"));
771 formatInfo.extensions.push_back(wxT("mp4"));
772 break;
773 case FMT_WMA2:
774 formatInfo.extensions.push_back(wxT("asf"));
775 formatInfo.extensions.push_back(wxT("wmv"));
776 break;
777 default:
778 break;
779 }
780 formatInfo.maxChannels = ExportFFmpegOptions::fmts[newfmt].maxchannels;
781 formatInfo.description = ExportFFmpegOptions::fmts[newfmt].description;
782
783 const int canmeta = ExportFFmpegOptions::fmts[newfmt].canmetadata;
784 formatInfo.canMetaData = canmeta && (canmeta == AV_CANMETA || canmeta <= avfver);
785
786 mFormatInfos.push_back(std::move(formatInfo));
787 }
788}
wxT("CloseDown"))
@ FMT_M4A
@ FMT_OTHER
@ FMT_WMA2
@ FMT_LAST
#define AV_CANMETA
Definition: FFmpegDefines.h:20
std::vector< FormatInfo > mFormatInfos
std::shared_ptr< FFmpegFunctions > mFFmpeg
static ExposedFormat fmts[]
List of export types.
bool compiledIn
support for this codec/format is compiled in (checked at runtime)
const int canmetadata
!=0 if format supports metadata, AV_CANMETA any avformat version, otherwise version support added
const TranslatableString description
format description (will be shown in export dialog)
const wxChar * name
format name (internal, should be unique; if not - export dialog may show unusual behaviour)
AudacityAVCodecID codecid
codec ID (see libavcodec/avcodec.h)
unsigned maxchannels
how many channels this format could handle
static std::shared_ptr< FFmpegFunctions > Load(bool fromUserPathOnly=false)
wxString format
Definition: ExportPlugin.h:35

References AV_CANMETA, ExposedFormat::canmetadata, ExposedFormat::codecid, ExposedFormat::compiledIn, ExposedFormat::description, anonymous_namespace{CloudProjectFileIOExtensions.cpp}::extension, FMT_LAST, FMT_M4A, FMT_OTHER, FMT_WMA2, ExportFFmpegOptions::fmts, FormatInfo::format, FFmpegFunctions::Load(), ExposedFormat::maxchannels, mFFmpeg, mFormatInfos, ExposedFormat::name, and wxT().

Here is the call graph for this function:

◆ ~ExportFFmpeg()

ExportFFmpeg::~ExportFFmpeg ( )
overridedefault

Member Function Documentation

◆ CheckFileName()

bool ExportFFmpeg::CheckFileName ( wxFileName &  filename,
int  format = 0 
) const
overridevirtual

Callback, called from GetFilename.

Reimplemented from ExportPlugin.

Definition at line 836 of file ExportFFmpeg.cpp.

837{
838 bool result = true;
839
840 // Show "Locate FFmpeg" dialog
842 if (!mFFmpeg)
843 {
846
847 return LoadFFmpeg(true);
848 }
849
850 return result;
851}
bool FindFFmpegLibs(wxWindow *parent)
Definition: FFmpeg.cpp:303
bool LoadFFmpeg(bool showerror)
Definition: FFmpeg.cpp:39

References FindFFmpegLibs(), FFmpegFunctions::Load(), LoadFFmpeg(), and mFFmpeg.

Here is the call graph for this function:

◆ CreateOptionsEditor()

std::unique_ptr< ExportOptionsEditor > ExportFFmpeg::CreateOptionsEditor ( int  formatIndex,
ExportOptionsEditor::Listener listener 
) const
overridevirtual

Creates format-dependent options editor, that is used to create a valid set of parameters to be used in exporting.

Parameters
listenerOption listener object that could be used by the editor to report on option changes.

Implements ExportPlugin.

Definition at line 793 of file ExportFFmpeg.cpp.

794{
796 {
797 case FMT_M4A:
798 return std::make_unique<PlainExportOptionsEditor>(AACOptions, listener);
799 case FMT_AC3:
800 return std::make_unique<PlainExportOptionsEditor>(
803 listener);
804 case FMT_AMRNB:
805 return std::make_unique<PlainExportOptionsEditor>(
808 listener);
809#ifdef SHOW_FFMPEG_OPUS_EXPORT
810 case FMT_OPUS:
811 return std::make_unique<PlainExportOptionsEditor>(OPUSOptions, listener);
812#endif
813 case FMT_WMA2:
814 return std::make_unique<PlainExportOptionsEditor>(
817 listener);
818 case FMT_OTHER:
819 return std::make_unique<ExportOptionsFFmpegCustomEditor>(listener);
820 }
821 return {};
822}
static int AdjustFormatIndex(int format)
@ FMT_AC3
@ FMT_AMRNB
std::vector< int > SampleRateList
const std::initializer_list< PlainExportOptionsEditor::OptionDesc > AMRNBOptions
const std::initializer_list< PlainExportOptionsEditor::OptionDesc > AC3Options
const std::initializer_list< PlainExportOptionsEditor::OptionDesc > AACOptions
const std::initializer_list< PlainExportOptionsEditor::OptionDesc > WMAOptions
ExportOptionsEditor::SampleRateList ToSampleRateList(const int *rates)
const std::initializer_list< PlainExportOptionsEditor::OptionDesc > OPUSOptions
Definition: ExportOpus.cpp:105

References anonymous_namespace{ExportFFmpeg.cpp}::AACOptions, anonymous_namespace{ExportFFmpeg.cpp}::AC3Options, AdjustFormatIndex(), anonymous_namespace{ExportFFmpeg.cpp}::AMRNBOptions, FMT_AC3, FMT_AMRNB, FMT_M4A, FMT_OTHER, FMT_WMA2, anonymous_namespace{ExportPCM.cpp}::format, anonymous_namespace{ExportFFmpeg.cpp}::iAC3SampleRates, anonymous_namespace{ExportFFmpeg.cpp}::iWMASampleRates, anonymous_namespace{ExportOpus.cpp}::OPUSOptions, anonymous_namespace{ExportFFmpeg.cpp}::ToSampleRateList(), and anonymous_namespace{ExportFFmpeg.cpp}::WMAOptions.

Here is the call graph for this function:

◆ CreateProcessor()

std::unique_ptr< ExportProcessor > ExportFFmpeg::CreateProcessor ( int  format) const
overridevirtual
Parameters
formatControl which of the multiple formats this exporter is capable of exporting should be used. Used where a single export plug-in handles a number of related formats, but they have separate entries in the Format drop-down list box. For example, the options to export to "Other PCM", "AIFF 16 Bit" and "WAV 16 Bit" are all the same libsndfile export plug-in, but with subformat set to 0, 1, and 2 respectively.

Implements ExportPlugin.

Definition at line 853 of file ExportFFmpeg.cpp.

854{
855 return std::make_unique<FFmpegExportProcessor>(mFFmpeg, format);
856}

References anonymous_namespace{ExportPCM.cpp}::format, and mFFmpeg.

◆ GetFormatCount()

int ExportFFmpeg::GetFormatCount ( ) const
overridevirtual

Implements ExportPlugin.

Definition at line 824 of file ExportFFmpeg.cpp.

825{
826 return static_cast<int>(mFormatInfos.size());
827}

References mFormatInfos.

◆ GetFormatInfo()

FormatInfo ExportFFmpeg::GetFormatInfo ( int  index) const
overridevirtual

Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn't guaranteed to be unique.

Parameters
indexShould not exceed the number of formats provided by GetFormatCount()

Implements ExportPlugin.

Definition at line 829 of file ExportFFmpeg.cpp.

830{
831 if(index >= 0 && index < mFormatInfos.size())
832 return mFormatInfos[index];
833 return mFormatInfos[FMT_OTHER];
834}

References FMT_OTHER, and mFormatInfos.

Member Data Documentation

◆ mFFmpeg

std::shared_ptr<FFmpegFunctions> ExportFFmpeg::mFFmpeg
mutableprivate

Definition at line 709 of file ExportFFmpeg.cpp.

Referenced by CheckFileName(), CreateProcessor(), and ExportFFmpeg().

◆ mFormatInfos

std::vector<FormatInfo> ExportFFmpeg::mFormatInfos
private

Definition at line 711 of file ExportFFmpeg.cpp.

Referenced by ExportFFmpeg(), GetFormatCount(), and GetFormatInfo().


The documentation for this class was generated from the following file: