From c098e4d2a3dcdc27df862048c7f421d9fda6b061 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 29 Jul 2007 09:06:38 +0000 Subject: [PATCH] Issue #466 - Fixed ffmpegsource with vfr videos. Also re-added the warning for dss. Avisynth provider *should* now be 100% reliable if ffmpegsource.dll is present. Originally committed to SVN as r1456. --- aegisub/video_context.cpp | 6 +++++- aegisub/video_provider.h | 2 ++ aegisub/video_provider_avs.cpp | 24 ++++++++++++++++++------ aegisub/video_provider_lavc.cpp | 1 + 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/aegisub/video_context.cpp b/aegisub/video_context.cpp index 3f9fa4f24..4e9e05ba3 100644 --- a/aegisub/video_context.cpp +++ b/aegisub/video_context.cpp @@ -306,7 +306,7 @@ void VideoContext::SetVideo(const wxString &filename) { // Set frame rate fps = provider->GetFPS(); - if (!isVfr) { + if (!isVfr || provider->IsNativelyByFrames()) { VFR_Input.SetCFR(fps); if (VFR_Output.GetFrameRateType() != VFR) VFR_Output.SetCFR(fps); } @@ -327,6 +327,10 @@ void VideoContext::SetVideo(const wxString &filename) { frame_n = 0; //UpdateDisplays(true); Refresh(true,true); + + // Show warning + wxString warning = provider->GetWarning(); + if (!warning.IsEmpty()) wxMessageBox(warning,_T("Warning"),wxICON_WARNING | wxOK); } catch (wxString &e) { diff --git a/aegisub/video_provider.h b/aegisub/video_provider.h index 4153e9475..21698ebf9 100644 --- a/aegisub/video_provider.h +++ b/aegisub/video_provider.h @@ -94,6 +94,8 @@ public: virtual int GetHeight()=0; // Returns the video height in pixels virtual double GetFPS()=0; // Get framerate in frames per second virtual void OverrideFrameTimeList(wxArrayInt list) {} // Override the list with the provided one, for VFR handling + virtual bool IsNativelyByFrames() { return false; } + virtual wxString GetWarning() { return _T(""); } }; diff --git a/aegisub/video_provider_avs.cpp b/aegisub/video_provider_avs.cpp index 4c2b5dfc9..5ec317c63 100644 --- a/aegisub/video_provider_avs.cpp +++ b/aegisub/video_provider_avs.cpp @@ -59,6 +59,7 @@ private: VideoInfo vi; AegiVideoFrame iframe; + bool usedDirectShow; wxString rendererCallString; int num_frames; @@ -66,6 +67,7 @@ private: double fps; wxArrayInt frameTime; + bool byFrame; PClip RGB32Video; PClip SubtitledVideo; @@ -96,6 +98,8 @@ public: int GetHeight() { return vi.height; }; void OverrideFrameTimeList(wxArrayInt list); + bool IsNativelyByFrames() { return byFrame; } + wxString GetWarning(); }; @@ -118,6 +122,7 @@ AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, double _fps) { fps = _fps; num_frames = 0; last_fnum = -1; + byFrame = false; AVSTRACE(_T("AvisynthVideoProvider: Loading Subtitles Renderer")); LoadRenderer(); @@ -160,7 +165,8 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Got AVS mutex")); AVSValue script; - bool usedDirectshow = false; + byFrame = false; + usedDirectShow = false; wxString extension = _filename.Right(4); extension.LowerCase(); @@ -186,6 +192,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori AVSValue args[2] = { videoFilename, false }; script = env->Invoke("AviSource", AVSValue(args,2), argnames); AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened .avi file without audio")); + byFrame = true; } // On Failure, fallback to DSS @@ -228,6 +235,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori // Some other format, such as mkv, mp4, ogm... try FFMpegSource and DirectShowSource else { // Try loading FFMpegSource + directshowOpen: bool ffsource = false; if (env->FunctionExists("ffmpegsource")) ffsource = true; if (!ffsource) { @@ -236,6 +244,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading FFMpegSource")); env->Invoke("LoadPlugin",env->SaveString(ffsourcepath.GetFullPath().mb_str(wxConvLocal))); AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loaded FFMpegSource")); + byFrame = true; } } @@ -250,7 +259,6 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori // DirectShowSource if (!ffsource) { - directshowOpen: AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening file with DirectShowSource")); // Try loading DirectShowSource2 @@ -293,7 +301,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori script = env->Invoke("DirectShowSource", AVSValue(args,4), argnames); } AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with DSS without audio")); - usedDirectshow = true; + usedDirectShow = true; } // Failed to find a suitable function @@ -324,9 +332,6 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Converted to RGB32")); } - // Directshow - //if (usedDirectshow) wxMessageBox(_T("Warning! The file is being opened using Avisynth's DirectShowSource, which has unreliable seeking. Frame numbers might not match the real number. PROCEED AT YOUR OWN RISK!"),_T("DirectShowSource warning"),wxICON_EXCLAMATION); - // Cache AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Finished opening video, AVS mutex will be released now")); return (env->Invoke("Cache", script)).AsClip(); @@ -556,4 +561,11 @@ void AvisynthVideoProvider::OverrideFrameTimeList(wxArrayInt list) { } +/////////////// +// Get warning +wxString AvisynthVideoProvider::GetWarning() { + if (usedDirectShow) return _("Warning! The file is being opened using Avisynth's DirectShowSource, which has unreliable seeking. Frame numbers might not match the real number. PROCEED AT YOUR OWN RISK!"); + else return _T(""); +} + #endif diff --git a/aegisub/video_provider_lavc.cpp b/aegisub/video_provider_lavc.cpp index d8e1dd241..b7ab9a813 100644 --- a/aegisub/video_provider_lavc.cpp +++ b/aegisub/video_provider_lavc.cpp @@ -110,6 +110,7 @@ public: int GetWidth(); int GetHeight(); double GetFPS(); + bool IsNativelyByFrames() { return true; } };