Audacity 3.2.0
Classes | Functions | Variables
FFmpeg.h File Reference
#include "audacity/Types.h"
#include "wxPanelWrapper.h"
#include "ShuttleGui.h"
#include "Prefs.h"
#include "Identifier.h"
#include "SampleFormat.h"
#include "FFmpegFunctions.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 65 of file FFmpeg.cpp.

66{
67 bool enabled = FFmpegEnabled.Read();
68 // 'false' means that no errors should be shown whatsoever
69 if (!LoadFFmpeg(false))
70 {
71 if (enabled)
72 {
74"FFmpeg was configured in Preferences and successfully loaded before, \
75\nbut this time Audacity failed to load it at startup. \
76\n\nYou may want to go back to Preferences > Libraries and re-configure it."),
77 XO("FFmpeg startup failed"));
78 }
79 }
80}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static BoolSetting FFmpegEnabled
Definition: FFmpeg.cpp:44
bool LoadFFmpeg(bool showerror)
Definition: FFmpeg.cpp:46
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:200

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

Referenced by AudacityApp::InitPart2().

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 310 of file FFmpeg.cpp.

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

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

◆ GetFFmpegVersion()

TranslatableString GetFFmpegVersion ( )

Definition at line 82 of file FFmpeg.cpp.

83{
84 auto ffmpeg = FFmpegFunctions::Load();
85
86 if (ffmpeg)
87 {
88 return Verbatim(
89 wxString::Format(
90 wxT("F(%d.%d.%d),C(%d.%d.%d),U(%d.%d.%d)"),
91 ffmpeg->AVFormatVersion.Major, ffmpeg->AVFormatVersion.Minor, ffmpeg->AVFormatVersion.Micro,
92 ffmpeg->AVCodecVersion.Major, ffmpeg->AVCodecVersion.Minor, ffmpeg->AVCodecVersion.Micro,
93 ffmpeg->AVUtilVersion.Major, ffmpeg->AVUtilVersion.Minor, ffmpeg->AVUtilVersion.Micro
94 ));
95 }
96
97 return XO("FFmpeg library not found");
98}
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 46 of file FFmpeg.cpp.

47{
48 auto ffmpeg = FFmpegFunctions::Load();
49
50 if (!ffmpeg)
51 {
52 FFmpegEnabled.Write(false);
53 gPrefs->Flush();
54 return false;
55 }
56 else
57 {
58 FFmpegEnabled.Write(true);
59 gPrefs->Flush();
60 return true;
61 }
62}
FileConfig * gPrefs
Definition: Prefs.cpp:70
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143

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

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

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

Variable Documentation

◆ FFmpegNotFoundDontShow

BoolSetting FFmpegNotFoundDontShow
extern