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.
This commit is contained in:
Rodrigo Braz Monteiro 2007-07-29 09:06:38 +00:00
parent 1aec7be708
commit c098e4d2a3
4 changed files with 26 additions and 7 deletions

View File

@ -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) {

View File

@ -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(""); }
};

View File

@ -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

View File

@ -110,6 +110,7 @@ public:
int GetWidth();
int GetHeight();
double GetFPS();
bool IsNativelyByFrames() { return true; }
};