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 737 of file ExportFFmpeg.cpp.

738{
740
741 int avfver = mFFmpeg ? mFFmpeg->AVFormatVersion.GetIntVersion() : 0;
742
743 int newfmt;
744 // Adds export types from the export type list
745 for (newfmt = 0; newfmt < FMT_LAST; newfmt++)
746 {
747 wxString shortname(ExportFFmpegOptions::fmts[newfmt].shortname);
748 // Don't hide export types when there's no av-libs, and don't hide FMT_OTHER
749 if (newfmt < FMT_OTHER && mFFmpeg)
750 {
751 // Format/Codec support is compiled in?
752 auto avoformat = mFFmpeg->GuessOutputFormat(shortname.mb_str(), nullptr, nullptr);
753 auto avcodec = mFFmpeg->CreateEncoder(mFFmpeg->GetAVCodecID(ExportFFmpegOptions::fmts[newfmt].codecid));
754
755 if (avoformat == NULL || avcodec == NULL)
756 {
758 continue;
759 }
760 }
761 FormatInfo formatInfo {};
762 formatInfo.format = ExportFFmpegOptions::fmts[newfmt].name;
763 formatInfo.extensions.push_back(ExportFFmpegOptions::fmts[newfmt].extension);
764 // For some types add other extensions
765 switch(newfmt)
766 {
767 case FMT_M4A:
768 formatInfo.extensions.push_back(wxT("3gp"));
769 formatInfo.extensions.push_back(wxT("m4r"));
770 formatInfo.extensions.push_back(wxT("mp4"));
771 break;
772 case FMT_WMA2:
773 formatInfo.extensions.push_back(wxT("asf"));
774 formatInfo.extensions.push_back(wxT("wmv"));
775 break;
776 default:
777 break;
778 }
779 formatInfo.maxChannels = ExportFFmpegOptions::fmts[newfmt].maxchannels;
780 formatInfo.description = ExportFFmpegOptions::fmts[newfmt].description;
781
782 const int canmeta = ExportFFmpegOptions::fmts[newfmt].canmetadata;
783 formatInfo.canMetaData = canmeta && (canmeta == AV_CANMETA || canmeta <= avfver);
784
785 mFormatInfos.push_back(std::move(formatInfo));
786 }
787}
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 835 of file ExportFFmpeg.cpp.

836{
837 bool result = true;
838
839 // Show "Locate FFmpeg" dialog
841 if (!mFFmpeg)
842 {
845
846 return LoadFFmpeg(true);
847 }
848
849 return result;
850}
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 792 of file ExportFFmpeg.cpp.

793{
795 {
796 case FMT_M4A:
797 return std::make_unique<PlainExportOptionsEditor>(AACOptions, listener);
798 case FMT_AC3:
799 return std::make_unique<PlainExportOptionsEditor>(
802 listener);
803 case FMT_AMRNB:
804 return std::make_unique<PlainExportOptionsEditor>(
807 listener);
808#ifdef SHOW_FFMPEG_OPUS_EXPORT
809 case FMT_OPUS:
810 return std::make_unique<PlainExportOptionsEditor>(OPUSOptions, listener);
811#endif
812 case FMT_WMA2:
813 return std::make_unique<PlainExportOptionsEditor>(
816 listener);
817 case FMT_OTHER:
818 return std::make_unique<ExportOptionsFFmpegCustomEditor>(listener);
819 }
820 return {};
821}
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 852 of file ExportFFmpeg.cpp.

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

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

◆ GetFormatCount()

int ExportFFmpeg::GetFormatCount ( ) const
overridevirtual

Implements ExportPlugin.

Definition at line 823 of file ExportFFmpeg.cpp.

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

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 828 of file ExportFFmpeg.cpp.

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

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: