Audacity 3.2.0
|
Performs actual export. More...
Public Member Functions | |
FFmpegExporter (std::shared_ptr< FFmpegFunctions > ffmpeg, const wxFileNameWrapper &filename, int numChannels, int subformat) | |
bool | Init (const char *shortname, AudacityProject *project, int sampleRate, const Tags *metadata, const ExportProcessor::Parameters ¶meters) |
Format initialization. More... | |
bool | EncodeAudioFrame (int16_t *pFrame, size_t frameSize) |
Encodes audio. More... | |
bool | Finalize () |
Flushes audio encoder. More... | |
std::unique_ptr< Mixer > | CreateMixer (const AudacityProject &project, bool selectionOnly, double startTime, double stopTime, MixerOptions::Downmix *mixerSpec) |
Private Member Functions | |
bool | AddTags (const Tags *metadata) |
Writes metadata. More... | |
void | SetMetadata (const Tags *tags, const char *name, const wxChar *tag) |
Sets individual metadata values. More... | |
bool | CheckSampleRate (int rate, int lowrate, int highrate, const int *sampRates) |
Check whether or not current project sample rate is compatible with the export codec. More... | |
int | AskResample (int bitrate, int rate, int lowrate, int highrate, const int *sampRates) |
Asks user to resample the project or cancel the export procedure. More... | |
bool | InitCodecs (int sampleRate, const ExportProcessor::Parameters ¶meters) |
Codec initialization. More... | |
void | WritePacket (AVPacketWrapper &packet) |
int | EncodeAudio (AVPacketWrapper &pkt, int16_t *audio_samples, int nb_samples) |
Private Attributes | |
std::shared_ptr< FFmpegFunctions > | mFFmpeg |
std::unique_ptr< AVOutputFormatWrapper > | mEncFormatDesc |
int | mDefaultFrameSize {} |
std::unique_ptr< AVStreamWrapper > | mEncAudioStream |
int | mEncAudioFifoOutBufSize {} |
wxFileNameWrapper | mName |
int | mSubFormat {} |
int | mBitRate {} |
int | mSampleRate {} |
unsigned | mChannels {} |
bool | mSupportsUTF8 {true} |
std::unique_ptr< FifoBuffer > | mEncAudioFifo |
AVDataBuffer< int16_t > | mEncAudioFifoOutBuf |
std::unique_ptr< AVFormatContextWrapper > | mEncFormatCtx |
std::unique_ptr< AVCodecContextWrapper > | mEncAudioCodecCtx |
Static Private Attributes | |
static constexpr auto | MaxAudioPacketSize { 128 * 1024 } |
Performs actual export.
Definition at line 588 of file ExportFFmpeg.cpp.
FFmpegExporter::FFmpegExporter | ( | std::shared_ptr< FFmpegFunctions > | ffmpeg, |
const wxFileNameWrapper & | filename, | ||
int | numChannels, | ||
int | subformat | ||
) |
Definition at line 714 of file ExportFFmpeg.cpp.
References FFmpegFunctions::Load(), and mFFmpeg.
|
private |
Writes metadata.
Definition at line 1694 of file ExportFFmpeg.cpp.
References AUDACITY_AV_CODEC_ID_AAC, mEncFormatDesc, mFFmpeg, SetMetadata(), TAG_ALBUM, TAG_ARTIST, TAG_COMMENTS, TAG_GENRE, TAG_TITLE, TAG_TRACK, and TAG_YEAR.
Referenced by Init().
|
private |
Asks user to resample the project or cancel the export procedure.
Definition at line 1740 of file ExportFFmpeg.cpp.
References eIsCreating, label, name, S, sampRates, wxDialogWrapper::SetName(), Verbatim(), wxT(), and XO().
Referenced by InitCodecs().
|
private |
Check whether or not current project sample rate is compatible with the export codec.
Definition at line 956 of file ExportFFmpeg.cpp.
References sampRates.
Referenced by InitCodecs().
std::unique_ptr< Mixer > FFmpegExporter::CreateMixer | ( | const AudacityProject & | project, |
bool | selectionOnly, | ||
double | startTime, | ||
double | stopTime, | ||
MixerOptions::Downmix * | mixerSpec | ||
) |
Definition at line 728 of file ExportFFmpeg.cpp.
References ExportPluginHelpers::CreateMixer(), int16Sample, mChannels, mDefaultFrameSize, mSampleRate, and project.
|
private |
Definition at line 1331 of file ExportFFmpeg.cpp.
References _, AUDACITY_AV_SAMPLE_FMT_FLT, AUDACITY_AV_SAMPLE_FMT_FLTP, AUDACITY_AV_SAMPLE_FMT_S16, AUDACITY_AV_SAMPLE_FMT_S16P, AUDACITY_AV_SAMPLE_FMT_S32, AUDACITY_AV_SAMPLE_FMT_S32P, AUDACITY_AV_SAMPLE_FMT_U8, AUDACITY_AV_SAMPLE_FMT_U8P, AUDACITY_AVERROR, AUDACITY_AVERROR_EOF, AVPacketWrapper::GetWrappedValue(), mEncAudioCodecCtx, mEncAudioStream, mFFmpeg, AVPacketWrapper::ResetData(), AVPacketWrapper::ResetTimestamps(), AVPacketWrapper::SetStreamIndex(), and WritePacket().
Referenced by EncodeAudioFrame(), and Finalize().
bool FFmpegExporter::EncodeAudioFrame | ( | int16_t * | pFrame, |
size_t | frameSize | ||
) |
Encodes audio.
Definition at line 1549 of file ExportFFmpeg.cpp.
References _, EncodeAudio(), mChannels, mDefaultFrameSize, mEncAudioCodecCtx, mEncAudioFifo, mEncAudioFifoOutBuf, mEncAudioFifoOutBufSize, and mFFmpeg.
bool FFmpegExporter::Finalize | ( | ) |
Flushes audio encoder.
Definition at line 1467 of file ExportFFmpeg.cpp.
References _, AUDACITY_AV_CODEC_CAP_SMALL_LAST_FRAME, EncodeAudio(), mDefaultFrameSize, mEncAudioCodecCtx, mEncAudioFifo, mEncAudioFifoOutBuf, mEncAudioFifoOutBufSize, mEncFormatCtx, mFFmpeg, and wxT().
bool FFmpegExporter::Init | ( | const char * | shortname, |
AudacityProject * | project, | ||
int | sampleRate, | ||
const Tags * | metadata, | ||
const ExportProcessor::Parameters & | parameters | ||
) |
Format initialization.
Definition at line 859 of file ExportFFmpeg.cpp.
References _, AddTags(), AUDACITY_AVFMT_NOFILE, AV_CANMETA, ExposedFormat::canmetadata, ExposedFormat::canutf8, ExportFFmpegOptions::fmts, Tags::Get(), InitCodecs(), mEncAudioCodecCtx, mEncAudioStream, mEncFormatCtx, mEncFormatDesc, mFFmpeg, mName, mSubFormat, mSupportsUTF8, OSINPUT, project, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, AVIOContextWrapper::Success, and XO().
|
private |
Codec initialization.
Definition at line 980 of file ExportFFmpeg.cpp.
References _, anonymous_namespace{ExportFFmpeg.cpp}::AACOptionIDQuality, anonymous_namespace{ExportFFmpeg.cpp}::AC3OptionIDBitRate, anonymous_namespace{ExportFFmpeg.cpp}::AMRNBOptionIDBitRate, AskResample(), AUDACITY_AV_CODEC_FLAG_GLOBAL_HEADER, AUDACITY_AV_CODEC_FLAG_QSCALE, AUDACITY_AV_CODEC_ID_AAC, AUDACITY_AV_CODEC_ID_AC3, AUDACITY_AV_SAMPLE_FMT_FLT, AUDACITY_AV_SAMPLE_FMT_FLTP, AUDACITY_AV_SAMPLE_FMT_NONE, AUDACITY_AV_SAMPLE_FMT_S16, AUDACITY_AV_SAMPLE_FMT_S16P, AUDACITY_AV_SAMPLE_FMT_S32, AUDACITY_AV_SAMPLE_FMT_S32P, AUDACITY_AV_SAMPLE_FMT_U8, AUDACITY_AV_SAMPLE_FMT_U8P, AUDACITY_AVERROR, AUDACITY_AVFMT_GLOBALHEADER, AUDACITY_FF_COMPLIANCE_EXPERIMENTAL, AUDACITY_FF_PROFILE_AAC_LOW, AUDACITY_FF_QP2LAMBDA, CheckSampleRate(), ExposedFormat::codecid, FMT_AC3, FMT_AMRNB, FMT_M4A, FMT_OTHER, FMT_WMA2, ExportFFmpegOptions::fmts, ExportPluginHelpers::GetParameterValue(), anonymous_namespace{ExportFFmpeg.cpp}::iAC3SampleRates, anonymous_namespace{ExportFFmpeg.cpp}::iWMASampleRates, MaxAudioPacketSize, mChannels, mDefaultFrameSize, mEncAudioCodecCtx, mEncAudioFifo, mEncAudioFifoOutBuf, mEncAudioFifoOutBufSize, mEncAudioStream, mEncFormatCtx, mEncFormatDesc, mFFmpeg, mSampleRate, mSubFormat, anonymous_namespace{ExportOpus.cpp}::OPUSOptionIDApplication, anonymous_namespace{ExportOpus.cpp}::OPUSOptionIDBitRate, anonymous_namespace{ExportOpus.cpp}::OPUSOptionIDCutoff, anonymous_namespace{ExportOpus.cpp}::OPUSOptionIDFrameDuration, anonymous_namespace{ExportOpus.cpp}::OPUSOptionIDVBRMode, anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, AVDictionaryWrapper::Set(), Verbatim(), anonymous_namespace{ExportFFmpeg.cpp}::WMAOptionIDBitRate, wxT(), and XO().
Referenced by Init().
|
private |
Sets individual metadata values.
Definition at line 1722 of file ExportFFmpeg.cpp.
References Tags::GetTag(), Tags::HasTag(), mEncFormatCtx, mSupportsUTF8, name, and AVDictionaryWrapper::Set().
Referenced by AddTags().
|
private |
Definition at line 1306 of file ExportFFmpeg.cpp.
References _, AUDACITY_AV_NOPTS_VALUE, AVPacketWrapper::GetDecompressionTimestamp(), AVPacketWrapper::GetDuration(), AVPacketWrapper::GetPresentationTimestamp(), AVPacketWrapper::GetWrappedValue(), mEncAudioCodecCtx, mEncAudioStream, mEncFormatCtx, mFFmpeg, AVPacketWrapper::RescaleDecompressionTimestamp(), AVPacketWrapper::RescaleDuration(), and AVPacketWrapper::RescalePresentationTimestamp().
Referenced by EncodeAudio().
|
staticconstexprprivate |
Definition at line 590 of file ExportFFmpeg.cpp.
Referenced by InitCodecs().
|
private |
Definition at line 649 of file ExportFFmpeg.cpp.
|
private |
Definition at line 651 of file ExportFFmpeg.cpp.
Referenced by CreateMixer(), EncodeAudioFrame(), and InitCodecs().
|
private |
Definition at line 642 of file ExportFFmpeg.cpp.
Referenced by CreateMixer(), EncodeAudioFrame(), Finalize(), and InitCodecs().
|
private |
Definition at line 658 of file ExportFFmpeg.cpp.
Referenced by EncodeAudio(), EncodeAudioFrame(), Finalize(), Init(), InitCodecs(), and WritePacket().
|
private |
Definition at line 655 of file ExportFFmpeg.cpp.
Referenced by EncodeAudioFrame(), Finalize(), and InitCodecs().
|
private |
Definition at line 656 of file ExportFFmpeg.cpp.
Referenced by EncodeAudioFrame(), Finalize(), and InitCodecs().
|
private |
Definition at line 644 of file ExportFFmpeg.cpp.
Referenced by EncodeAudioFrame(), Finalize(), and InitCodecs().
|
private |
Definition at line 643 of file ExportFFmpeg.cpp.
Referenced by EncodeAudio(), Init(), InitCodecs(), and WritePacket().
|
private |
Definition at line 657 of file ExportFFmpeg.cpp.
Referenced by Finalize(), Init(), InitCodecs(), SetMetadata(), and WritePacket().
|
private |
Definition at line 641 of file ExportFFmpeg.cpp.
Referenced by AddTags(), Init(), and InitCodecs().
|
private |
Definition at line 639 of file ExportFFmpeg.cpp.
Referenced by AddTags(), EncodeAudio(), EncodeAudioFrame(), FFmpegExporter(), Finalize(), Init(), InitCodecs(), and WritePacket().
|
private |
Definition at line 646 of file ExportFFmpeg.cpp.
Referenced by Init().
|
private |
Definition at line 650 of file ExportFFmpeg.cpp.
Referenced by CreateMixer(), and InitCodecs().
|
private |
Definition at line 648 of file ExportFFmpeg.cpp.
Referenced by Init(), and InitCodecs().
|
private |
Definition at line 652 of file ExportFFmpeg.cpp.
Referenced by Init(), and SetMetadata().