Add option to set FFMS2 logging level (i.e. how much spam FFmpeg prints to STDERR).

Option is called "ffmpegsource log level" and possible values are (in order of increasing spam) quiet, panic, fatal, error, warning, info, verbose, debug. The default is quiet, and I strongly recommend avoiding anything above warning.

Originally committed to SVN as r3248.
This commit is contained in:
Karl Blomster 2009-07-24 01:41:16 +00:00
parent af6492d867
commit f59dcf19f6
5 changed files with 46 additions and 0 deletions

View File

@ -67,6 +67,8 @@ FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(wxString filename) {
AudioSource = NULL;
SetLogLevel();
try {
LoadAudio(filename);
} catch (...) {

View File

@ -106,6 +106,7 @@ FFIndex *FFmpegSourceProvider::DoIndexing(FFIndexer *Indexer, const wxString &Ca
return Index;
}
///////////
// Find all tracks of the given typo and return their track numbers and respective codec names
std::map<int,wxString> FFmpegSourceProvider::GetTracksOfType(FFIndexer *Indexer, FFMS_TrackType Type) {
@ -122,6 +123,7 @@ std::map<int,wxString> FFmpegSourceProvider::GetTracksOfType(FFIndexer *Indexer,
return TrackList;
}
///////////
// Ask user for which track he wants to load
int FFmpegSourceProvider::AskForTrackSelection(const std::map<int,wxString> &TrackList, FFMS_TrackType Type) {
@ -147,6 +149,31 @@ int FFmpegSourceProvider::AskForTrackSelection(const std::map<int,wxString> &Tra
return TrackNumbers[Choice];
}
///////////
// Set ffms2 log level according to setting in config.dat
void FFmpegSourceProvider::SetLogLevel() {
wxString LogLevel = Options.AsText(_T("FFmpegSource log level"));
if (!LogLevel.CmpNoCase(_T("panic")))
FFMS_SetLogLevel(FFMS_LOG_PANIC);
else if (!LogLevel.CmpNoCase(_T("fatal")))
FFMS_SetLogLevel(FFMS_LOG_FATAL);
else if (!LogLevel.CmpNoCase(_T("error")))
FFMS_SetLogLevel(FFMS_LOG_ERROR);
else if (!LogLevel.CmpNoCase(_T("warning")))
FFMS_SetLogLevel(FFMS_LOG_WARNING);
else if (!LogLevel.CmpNoCase(_T("info")))
FFMS_SetLogLevel(FFMS_LOG_INFO);
else if (!LogLevel.CmpNoCase(_T("verbose")))
FFMS_SetLogLevel(FFMS_LOG_VERBOSE);
else if (!LogLevel.CmpNoCase(_T("debug")))
FFMS_SetLogLevel(FFMS_LOG_DEBUG);
else
FFMS_SetLogLevel(FFMS_LOG_QUIET);
}
/////////////////////
// Creates a name for the ffmpegsource2 index and prepares the folder if it doesn't exist
// method by amz

View File

@ -52,6 +52,19 @@
class FFmpegSourceProvider {
friend class FFmpegSourceCacheCleaner;
public:
// constants stolen from avutil/log.h
// hope the ffmpeg devs don't change them around too much
enum FFMS_LogLevel {
FFMS_LOG_QUIET = -8,
FFMS_LOG_PANIC = 0,
FFMS_LOG_FATAL = 8,
FFMS_LOG_ERROR = 16,
FFMS_LOG_WARNING = 24,
FFMS_LOG_INFO = 32,
FFMS_LOG_VERBOSE = 40,
FFMS_LOG_DEBUG = 48,
};
struct IndexingProgressDialog {
volatile bool IndexingCanceled;
DialogProgress *ProgressDialog;
@ -66,6 +79,7 @@ public:
std::map<int,wxString> GetTracksOfType(FFIndexer *Indexer, FFMS_TrackType Type);
int AskForTrackSelection(const std::map<int,wxString>& TrackList, FFMS_TrackType Type);
wxString GetCacheFilename(const wxString& filename);
void SetLogLevel();
virtual ~FFmpegSourceProvider() {}
};

View File

@ -176,6 +176,7 @@ void OptionsManager::LoadDefaults(bool onlyDefaults,bool doOverride) {
SetInt(_T("FFmpegSource max cache size"),42);
SetInt(_T("FFmpegSource max cache files"),20);
SetInt(_T("FFmpegSource always index all tracks"), true);
SetText(_T("FFmpegSource log level"), _T("quiet"));
// Audio Options
SetModificationType(MOD_AUTOMATIC);

View File

@ -75,6 +75,8 @@ FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(wxString filename) {
MsgSize = sizeof(FFMSErrMsg);
ErrorMsg = _T("FFmpegSource video provider: ");
SetLogLevel();
// and here we go
try {
LoadVideo(filename);