Audacity 3.2.0
Classes | Functions | Variables
FFmpeg.h File Reference
#include "wxPanelWrapper.h"
#include "Prefs.h"
Include dependency graph for FFmpeg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FFmpegNotFoundDialog
 

Functions

TranslatableString GetFFmpegVersion ()
 
void FFmpegStartup ()
 
bool LoadFFmpeg (bool showerror)
 
bool FindFFmpegLibs (wxWindow *parent=nullptr)
 

Variables

BoolSetting FFmpegNotFoundDontShow
 

Function Documentation

◆ FFmpegStartup()

void FFmpegStartup ( )

Called during Audacity start-up to try and load the ffmpeg libraries

Definition at line 58 of file FFmpeg.cpp.

59{
60 bool enabled = FFmpegEnabled.Read();
61 // 'false' means that no errors should be shown whatsoever
62 if (!LoadFFmpeg(false))
63 {
64 if (enabled)
65 {
67"FFmpeg was configured in Preferences and successfully loaded before, \
68\nbut this time Audacity failed to load it at startup. \
69\n\nYou may want to go back to Preferences > Libraries and re-configure it."),
70 XO("FFmpeg startup failed"));
71 }
72 }
73}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static BoolSetting FFmpegEnabled
Definition: FFmpeg.cpp:37
bool LoadFFmpeg(bool showerror)
Definition: FFmpeg.cpp:39
XO("Cut/Copy/Paste")
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207

References AudacityMessageBox(), FFmpegEnabled, LoadFFmpeg(), Setting< T >::Read(), and XO().

Referenced by ModuleDispatch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindFFmpegLibs()

bool FindFFmpegLibs ( wxWindow *  parent = nullptr)

Definition at line 303 of file FFmpeg.cpp.

304{
305 wxString path;
306
307#if defined(__WXMSW__)
308 const wxString name = wxT("avformat.dll");
309#elif defined(__WXMAC__)
310 const wxString name = wxT("libavformat.dylib");
311#else
312 const wxString name = wxT("libavformat.so");
313#endif
314
315 wxLogMessage(wxT("Looking for FFmpeg libraries..."));
316
317 auto searchPaths = FFmpegFunctions::GetSearchPaths(false);
318
319 if (!searchPaths.empty())
320 path = searchPaths.front();
321
322 FindFFmpegDialog fd(parent, path, name);
323
324 if (fd.ShowModal() == wxID_CANCEL) {
325 wxLogMessage(wxT("User canceled the dialog. Failed to find FFmpeg libraries."));
326 return false;
327 }
328
329 path = fd.GetLibPath();
330
331 const wxFileName fileName(path);
332
333 if (fileName.FileExists())
334 path = fileName.GetPath();
335
336 wxLogMessage(wxT("User-specified path = '%s'"), path);
337
338 SettingTransaction transaction;
339 AVFormatPath.Write(path);
340
341 // Try to load FFmpeg from the user provided path
342 if (!FFmpegFunctions::Load(true))
343 {
344 wxLogError(wxT("User-specified path does not contain FFmpeg libraries."));
345 return false;
346 }
347
348 transaction.Commit();
349
350 wxLogMessage(wxT("User-specified FFmpeg file exists. Success."));
351
352 return true;
353}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:76
StringSetting AVFormatPath
Allows user to locate libav* libraries.
Definition: FFmpeg.cpp:106
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:259
Extend SettingScope with Commit() which flushes updates in a batch.
Definition: Prefs.h:149
static std::vector< wxString > GetSearchPaths(bool fromUserPathOnly)
static std::shared_ptr< FFmpegFunctions > Load(bool fromUserPathOnly=false)

References AVFormatPath, SettingTransaction::Commit(), FindFFmpegDialog::GetLibPath(), FFmpegFunctions::GetSearchPaths(), FFmpegFunctions::Load(), name, Setting< T >::Write(), and wxT().

Referenced by anonymous_namespace{ExportFFmpeg.cpp}::ExportOptionsFFmpegCustomEditor::CheckFFmpeg(), ExportFFmpeg::CheckFileName(), and anonymous_namespace{FFmpegPrefs.cpp}::OnFFmpegFindButton().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFFmpegVersion()

TranslatableString GetFFmpegVersion ( )

Definition at line 75 of file FFmpeg.cpp.

76{
77 auto ffmpeg = FFmpegFunctions::Load();
78
79 if (ffmpeg)
80 {
81 return Verbatim(
82 wxString::Format(
83 wxT("F(%d.%d.%d),C(%d.%d.%d),U(%d.%d.%d)"),
84 ffmpeg->AVFormatVersion.Major, ffmpeg->AVFormatVersion.Minor, ffmpeg->AVFormatVersion.Micro,
85 ffmpeg->AVCodecVersion.Major, ffmpeg->AVCodecVersion.Minor, ffmpeg->AVCodecVersion.Micro,
86 ffmpeg->AVUtilVersion.Major, ffmpeg->AVUtilVersion.Minor, ffmpeg->AVUtilVersion.Micro
87 ));
88 }
89
90 return XO("FFmpeg library not found");
91}
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.

References FFmpegFunctions::Load(), Verbatim(), wxT(), and XO().

Referenced by anonymous_namespace{FFmpegPrefs.cpp}::SetFFmpegVersionText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadFFmpeg()

bool LoadFFmpeg ( bool  showerror)

Definition at line 39 of file FFmpeg.cpp.

40{
41 auto ffmpeg = FFmpegFunctions::Load();
42
43 if (!ffmpeg)
44 {
45 FFmpegEnabled.Write(false);
46 gPrefs->Flush();
47 return false;
48 }
49 else
50 {
51 FFmpegEnabled.Write(true);
52 gPrefs->Flush();
53 return true;
54 }
55}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
virtual bool Flush() noexcept=0

References FFmpegEnabled, audacity::BasicSettings::Flush(), gPrefs, FFmpegFunctions::Load(), and Setting< T >::Write().

Referenced by anonymous_namespace{ExportFFmpeg.cpp}::ExportOptionsFFmpegCustomEditor::CheckFFmpeg(), ExportFFmpeg::CheckFileName(), FFmpegStartup(), and anonymous_namespace{FFmpegPrefs.cpp}::OnFFmpegFindButton().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ FFmpegNotFoundDontShow

BoolSetting FFmpegNotFoundDontShow
extern