diff --git a/aegisub/src/audio_provider_ffmpegsource.cpp b/aegisub/src/audio_provider_ffmpegsource.cpp index 2448197e1..24254a2d2 100644 --- a/aegisub/src/audio_provider_ffmpegsource.cpp +++ b/aegisub/src/audio_provider_ffmpegsource.cpp @@ -67,6 +67,8 @@ FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(wxString filename) { AudioSource = NULL; + SetLogLevel(); + try { LoadAudio(filename); } catch (...) { diff --git a/aegisub/src/ffmpegsource_common.cpp b/aegisub/src/ffmpegsource_common.cpp index 224287c6e..923ea5a2d 100644 --- a/aegisub/src/ffmpegsource_common.cpp +++ b/aegisub/src/ffmpegsource_common.cpp @@ -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 FFmpegSourceProvider::GetTracksOfType(FFIndexer *Indexer, FFMS_TrackType Type) { @@ -122,6 +123,7 @@ std::map FFmpegSourceProvider::GetTracksOfType(FFIndexer *Indexer, return TrackList; } + /////////// // Ask user for which track he wants to load int FFmpegSourceProvider::AskForTrackSelection(const std::map &TrackList, FFMS_TrackType Type) { @@ -147,6 +149,31 @@ int FFmpegSourceProvider::AskForTrackSelection(const std::map &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 diff --git a/aegisub/src/ffmpegsource_common.h b/aegisub/src/ffmpegsource_common.h index e2a1f2e4d..43977d9ee 100644 --- a/aegisub/src/ffmpegsource_common.h +++ b/aegisub/src/ffmpegsource_common.h @@ -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 GetTracksOfType(FFIndexer *Indexer, FFMS_TrackType Type); int AskForTrackSelection(const std::map& TrackList, FFMS_TrackType Type); wxString GetCacheFilename(const wxString& filename); + void SetLogLevel(); virtual ~FFmpegSourceProvider() {} }; diff --git a/aegisub/src/options.cpp b/aegisub/src/options.cpp index c60373fef..395c70633 100644 --- a/aegisub/src/options.cpp +++ b/aegisub/src/options.cpp @@ -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); diff --git a/aegisub/src/video_provider_ffmpegsource.cpp b/aegisub/src/video_provider_ffmpegsource.cpp index 0bc9fbea5..db8c0448e 100644 --- a/aegisub/src/video_provider_ffmpegsource.cpp +++ b/aegisub/src/video_provider_ffmpegsource.cpp @@ -75,6 +75,8 @@ FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(wxString filename) { MsgSize = sizeof(FFMSErrMsg); ErrorMsg = _T("FFmpegSource video provider: "); + SetLogLevel(); + // and here we go try { LoadVideo(filename);