//------ ODDecodeFFmpegFileDecoder ODFFmpegDecoder::ODFFmpegDecoder(const wxString & fileName, const ScsPtr &scs, ODDecodeFFmpegTask::Streams &&channels, const std::shared_ptr<FFmpegContext> &context, int streamIndex) :ODFileDecoder(fileName), //mSamplesDone(0), mScs(scs), mContext(context), mNumSamplesInCache(0), mCurrentLen(0), mSeekingAllowedStatus(ODFFMPEG_SEEKING_TEST_UNKNOWN), mStreamIndex(streamIndex) { PickFFmpegLibs(); //do a shallow copy of the 2d array. mChannels = std::move(channels); // get the current stream start time. int64_t stream_delay = 0; const auto sc = mScs->get()[streamIndex].get(); if (sc->m_stream->start_time != int64_t(AV_NOPTS_VALUE) && sc->m_stream->start_time > 0) { stream_delay = sc->m_stream->start_time; } mCurrentPos = double(stream_delay) / AV_TIME_BASE; //TODO: add a ref counter to scs? This will be necessary if we want to allow copy and paste of not-yet decoded //ODDecodeBlockFiles that point to FFmpeg files. }
ExportFFmpeg::ExportFFmpeg() : ExportPlugin() { mEncFormatCtx = NULL; // libavformat's context for our output file mEncFormatDesc = NULL; // describes our output file to libavformat mEncAudioStream = NULL; // the output audio stream (may remain NULL) mEncAudioCodecCtx = NULL; // the encoder for the output audio stream mEncAudioEncodedBuf = NULL; // buffer to hold frames encoded by the encoder #define MAX_AUDIO_PACKET_SIZE (128 * 1024) mEncAudioEncodedBufSiz = 4*MAX_AUDIO_PACKET_SIZE; mEncAudioFifoOutBuf = NULL; // buffer to read _out_ of the FIFO into mSampleRate = 0; mSupportsUTF8 = true; PickFFmpegLibs(); // DropFFmpegLibs() call is in ExportFFmpeg::Destroy() int newfmt; // Adds export types from the export type list for (newfmt = 0; newfmt < FMT_LAST; newfmt++) { wxString shortname(ExportFFmpegOptions::fmts[newfmt].shortname); //Don't hide export types when there's no av-libs, and don't hide FMT_OTHER if (newfmt < FMT_OTHER && FFmpegLibsInst->ValidLibsLoaded()) { // Format/Codec support is compiled in? AVOutputFormat *avoformat = FFmpegLibsInst->guess_format(shortname.mb_str(), NULL, NULL); AVCodec *avcodec = FFmpegLibsInst->avcodec_find_encoder(ExportFFmpegOptions::fmts[newfmt].codecid); if (avoformat == NULL || avcodec == NULL) { ExportFFmpegOptions::fmts[newfmt].compiledIn = false; continue; } } int fmtindex = AddFormat() - 1; SetFormat(ExportFFmpegOptions::fmts[newfmt].name,fmtindex); AddExtension(ExportFFmpegOptions::fmts[newfmt].extension,fmtindex); // For some types add other extensions switch(newfmt) { case FMT_M4A: AddExtension(wxString(wxT("3gp")),fmtindex); AddExtension(wxString(wxT("m4r")),fmtindex); AddExtension(wxString(wxT("mp4")),fmtindex); break; case FMT_WMA2: AddExtension(wxString(wxT("asf")),fmtindex); AddExtension(wxString(wxT("wmv")),fmtindex); break; default: break; } SetMaxChannels(ExportFFmpegOptions::fmts[newfmt].maxchannels,fmtindex); SetCanMetaData(ExportFFmpegOptions::fmts[newfmt].canmetadata,fmtindex); SetDescription(ExportFFmpegOptions::fmts[newfmt].description,fmtindex); } }
static bool CheckFFmpegPresence() { bool result = true; PickFFmpegLibs(); if (!FFmpegLibsInst->ValidLibsLoaded()) { wxMessageBox(_("Properly configured FFmpeg is required to proceed.\nYou can configure it at Preferences > Libraries.")); result = false; } DropFFmpegLibs(); return result; }
FFmpegImportFileHandle::FFmpegImportFileHandle(const wxString & name) : ImportFileHandle(name) { PickFFmpegLibs(); mStreamInfo = new wxArrayString(); mFormatContext = NULL; mNumStreams = 0; mScs = NULL; mCancelled =false; mName = name; mChannels = NULL; }
FFmpegImportFileHandle::FFmpegImportFileHandle(const wxString & name) : ImportFileHandle(name) { PickFFmpegLibs(); mFormatContext = NULL; mNumStreams = 0; mCancelled = false; mStopped = false; mName = name; mProgressPos = 0; mProgressLen = 1; }
wxString GetFFmpegVersion(wxWindow * WXUNUSED(parent)) { PickFFmpegLibs(); wxString versionString = _("FFmpeg library not found"); if (FFmpegLibsInst()->ValidLibsLoaded()) { versionString = FFmpegLibsInst()->GetLibraryVersion(); } DropFFmpegLibs(); return versionString; }
wxString GetFFmpegVersion(wxWindow *parent, bool prompt) { PickFFmpegLibs(); wxString versionString = _("FFmpeg library not found"); if (prompt) { FFmpegLibsInst->FindLibs(parent); } if (FFmpegLibsInst->LoadLibs(parent, false)) { versionString = FFmpegLibsInst->GetLibraryVersion(); } DropFFmpegLibs(); return versionString; }
bool LoadFFmpeg(bool showerror) { PickFFmpegLibs(); if (FFmpegLibsInst->ValidLibsLoaded()) { DropFFmpegLibs(); return true; } if (!FFmpegLibsInst->LoadLibs(NULL,showerror)) { DropFFmpegLibs(); gPrefs->Write(wxT("/FFmpeg/Enabled"), false); return false; } else { gPrefs->Write(wxT("/FFmpeg/Enabled"), true); return true; } }
ExportFFmpegOptions::ExportFFmpegOptions(wxWindow *parent) : wxDialog(NULL, wxID_ANY, wxString(_("Specify Other Options")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) { ShuttleGui S(this, eIsCreatingFromPrefs); PickFFmpegLibs(); FFmpegLibsInst->LoadLibs(NULL,false); mPresets = new FFmpegPresets(); mPresetNames = mPresets->GetPresetList(); //FetchPresetList(); FetchFormatList(); FetchCodecList(); for (unsigned int i = 0; i < 6; i++) { mPredictionOrderMethodLabels.Add(i); mPredictionOrderMethodNames.Add(wxString::Format(wxT("%s"),PredictionOrderMethodNames[i])); } for (unsigned int i=0; i < (sizeof(iAACProfileValues)/sizeof(int)); i++) { mProfileNames.Add(wxString::Format(wxT("%s"),iAACProfileNames[i])); mProfileLabels.Add(iAACProfileValues[i]); } PopulateOrExchange(S); //Select the format that was selected last time this dialog was closed mFormatList->Select(mFormatList->FindString(gPrefs->Read(wxT("/FileFormats/FFmpegFormat")))); DoOnFormatList(); //Select the codec that was selected last time this dialog was closed AVCodec *codec = FFmpegLibsInst->avcodec_find_encoder((CodecID)gPrefs->Read(wxT("/FileFormats/FFmpegCodec"),(long)CODEC_ID_NONE)); if (codec != NULL) mCodecList->Select(mCodecList->FindString(wxString::FromUTF8(codec->name))); DoOnCodecList(); }
//------ ODDecodeFFmpegFileDecoder ODFFmpegDecoder::ODFFmpegDecoder(const wxString & fileName, streamContext** scs,int numStreams,WaveTrack*** channels, AVFormatContext* formatContext, int streamIndex) :ODFileDecoder(fileName), //mSamplesDone(0), mNumStreams(numStreams), mScs(scs), mFormatContext(formatContext), mNumSamplesInCache(0), mCurrentLen(0), mSeekingAllowedStatus(ODFFMPEG_SEEKING_TEST_UNKNOWN), mStreamIndex(streamIndex) { PickFFmpegLibs(); //do a shallow copy of the 2d array. mChannels = new WaveTrack **[mNumStreams]; for (int s = 0; s < mNumStreams; s++) { mChannels[s] = new WaveTrack *[mScs[s]->m_stream->codec->channels]; int c; for (c = 0; c < mScs[s]->m_stream->codec->channels; c++) { mChannels[s][c] = channels[s][c]; } } // get the current stream start time. int64_t stream_delay = 0; if (mScs[streamIndex]->m_stream->start_time != int64_t(AV_NOPTS_VALUE) && mScs[streamIndex]->m_stream->start_time > 0) { stream_delay = mScs[streamIndex]->m_stream->start_time; } mCurrentPos = double(stream_delay) / AV_TIME_BASE; //TODO: add a ref counter to scs? This will be necessary if we want to allow copy and paste of not-yet decoded //ODDecodeBlockFiles that point to FFmpeg files. }
void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & WXUNUSED(event)) { #ifdef USE_FFMPEG FFmpegLibs* FFmpegLibsInst = PickFFmpegLibs(); bool showerrs = #if defined(__WXDEBUG__) true; #else false; #endif FFmpegLibsInst->FreeLibs(); // Load the libs ('true' means that all errors will be shown) bool locate = !LoadFFmpeg(showerrs); // Libs are fine, don't show "locate" dialog unless user really wants it if (!locate) { int response = wxMessageBox(_("Audacity has automatically detected valid FFmpeg libraries.\nDo you still want to locate them manually?"), wxT("Success"), wxCENTRE | wxYES_NO | wxNO_DEFAULT |wxICON_QUESTION); if (response == wxYES) { locate = true; } } if (locate) { // Show "Locate FFmpeg" dialog FFmpegLibsInst->FindLibs(this); FFmpegLibsInst->FreeLibs(); LoadFFmpeg(showerrs); } SetFFmpegVersionText(); DropFFmpegLibs(); #endif }
ExportFFmpeg::ExportFFmpeg() : ExportPlugin() { mEncFormatDesc = NULL; // describes our output file to libavformat mEncAudioStream = NULL; // the output audio stream (may remain NULL) #define MAX_AUDIO_PACKET_SIZE (128 * 1024) mEncAudioFifoOutBufSiz = 0; mSampleRate = 0; mSupportsUTF8 = true; PickFFmpegLibs(); // DropFFmpegLibs() call is in ExportFFmpeg destructor int avfver = FFmpegLibsInst->ValidLibsLoaded() ? avformat_version() : 0; int newfmt; // Adds export types from the export type list for (newfmt = 0; newfmt < FMT_LAST; newfmt++) { wxString shortname(ExportFFmpegOptions::fmts[newfmt].shortname); //Don't hide export types when there's no av-libs, and don't hide FMT_OTHER if (newfmt < FMT_OTHER && FFmpegLibsInst->ValidLibsLoaded()) { // Format/Codec support is compiled in? AVOutputFormat *avoformat = av_guess_format(shortname.mb_str(), NULL, NULL); AVCodec *avcodec = avcodec_find_encoder(ExportFFmpegOptions::fmts[newfmt].codecid); if (avoformat == NULL || avcodec == NULL) { ExportFFmpegOptions::fmts[newfmt].compiledIn = false; continue; } } int fmtindex = AddFormat() - 1; SetFormat(ExportFFmpegOptions::fmts[newfmt].name,fmtindex); AddExtension(ExportFFmpegOptions::fmts[newfmt].extension,fmtindex); // For some types add other extensions switch(newfmt) { case FMT_M4A: AddExtension(wxString(wxT("3gp")),fmtindex); AddExtension(wxString(wxT("m4r")),fmtindex); AddExtension(wxString(wxT("mp4")),fmtindex); break; case FMT_WMA2: AddExtension(wxString(wxT("asf")),fmtindex); AddExtension(wxString(wxT("wmv")),fmtindex); break; default: break; } SetMaxChannels(ExportFFmpegOptions::fmts[newfmt].maxchannels,fmtindex); SetDescription(ExportFFmpegOptions::fmts[newfmt].description,fmtindex); int canmeta = ExportFFmpegOptions::fmts[newfmt].canmetadata; if (canmeta && (canmeta == AV_VERSION_INT(-1,-1,-1) || canmeta <= avfver)) { SetCanMetaData(true,fmtindex); } else { SetCanMetaData(false,fmtindex); } } }