forked from mia/Aegisub
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:
parent
1aec7be708
commit
c098e4d2a3
|
@ -306,7 +306,7 @@ void VideoContext::SetVideo(const wxString &filename) {
|
||||||
|
|
||||||
// Set frame rate
|
// Set frame rate
|
||||||
fps = provider->GetFPS();
|
fps = provider->GetFPS();
|
||||||
if (!isVfr) {
|
if (!isVfr || provider->IsNativelyByFrames()) {
|
||||||
VFR_Input.SetCFR(fps);
|
VFR_Input.SetCFR(fps);
|
||||||
if (VFR_Output.GetFrameRateType() != VFR) VFR_Output.SetCFR(fps);
|
if (VFR_Output.GetFrameRateType() != VFR) VFR_Output.SetCFR(fps);
|
||||||
}
|
}
|
||||||
|
@ -327,6 +327,10 @@ void VideoContext::SetVideo(const wxString &filename) {
|
||||||
frame_n = 0;
|
frame_n = 0;
|
||||||
//UpdateDisplays(true);
|
//UpdateDisplays(true);
|
||||||
Refresh(true,true);
|
Refresh(true,true);
|
||||||
|
|
||||||
|
// Show warning
|
||||||
|
wxString warning = provider->GetWarning();
|
||||||
|
if (!warning.IsEmpty()) wxMessageBox(warning,_T("Warning"),wxICON_WARNING | wxOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (wxString &e) {
|
catch (wxString &e) {
|
||||||
|
|
|
@ -94,6 +94,8 @@ public:
|
||||||
virtual int GetHeight()=0; // Returns the video height in pixels
|
virtual int GetHeight()=0; // Returns the video height in pixels
|
||||||
virtual double GetFPS()=0; // Get framerate in frames per second
|
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 void OverrideFrameTimeList(wxArrayInt list) {} // Override the list with the provided one, for VFR handling
|
||||||
|
virtual bool IsNativelyByFrames() { return false; }
|
||||||
|
virtual wxString GetWarning() { return _T(""); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ private:
|
||||||
VideoInfo vi;
|
VideoInfo vi;
|
||||||
AegiVideoFrame iframe;
|
AegiVideoFrame iframe;
|
||||||
|
|
||||||
|
bool usedDirectShow;
|
||||||
wxString rendererCallString;
|
wxString rendererCallString;
|
||||||
|
|
||||||
int num_frames;
|
int num_frames;
|
||||||
|
@ -66,6 +67,7 @@ private:
|
||||||
|
|
||||||
double fps;
|
double fps;
|
||||||
wxArrayInt frameTime;
|
wxArrayInt frameTime;
|
||||||
|
bool byFrame;
|
||||||
|
|
||||||
PClip RGB32Video;
|
PClip RGB32Video;
|
||||||
PClip SubtitledVideo;
|
PClip SubtitledVideo;
|
||||||
|
@ -96,6 +98,8 @@ public:
|
||||||
int GetHeight() { return vi.height; };
|
int GetHeight() { return vi.height; };
|
||||||
|
|
||||||
void OverrideFrameTimeList(wxArrayInt list);
|
void OverrideFrameTimeList(wxArrayInt list);
|
||||||
|
bool IsNativelyByFrames() { return byFrame; }
|
||||||
|
wxString GetWarning();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,6 +122,7 @@ AvisynthVideoProvider::AvisynthVideoProvider(wxString _filename, double _fps) {
|
||||||
fps = _fps;
|
fps = _fps;
|
||||||
num_frames = 0;
|
num_frames = 0;
|
||||||
last_fnum = -1;
|
last_fnum = -1;
|
||||||
|
byFrame = false;
|
||||||
|
|
||||||
AVSTRACE(_T("AvisynthVideoProvider: Loading Subtitles Renderer"));
|
AVSTRACE(_T("AvisynthVideoProvider: Loading Subtitles Renderer"));
|
||||||
LoadRenderer();
|
LoadRenderer();
|
||||||
|
@ -160,7 +165,8 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Got AVS mutex"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Got AVS mutex"));
|
||||||
AVSValue script;
|
AVSValue script;
|
||||||
|
|
||||||
bool usedDirectshow = false;
|
byFrame = false;
|
||||||
|
usedDirectShow = false;
|
||||||
|
|
||||||
wxString extension = _filename.Right(4);
|
wxString extension = _filename.Right(4);
|
||||||
extension.LowerCase();
|
extension.LowerCase();
|
||||||
|
@ -186,6 +192,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
|
||||||
AVSValue args[2] = { videoFilename, false };
|
AVSValue args[2] = { videoFilename, false };
|
||||||
script = env->Invoke("AviSource", AVSValue(args,2), argnames);
|
script = env->Invoke("AviSource", AVSValue(args,2), argnames);
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened .avi file without audio"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened .avi file without audio"));
|
||||||
|
byFrame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Failure, fallback to DSS
|
// 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
|
// Some other format, such as mkv, mp4, ogm... try FFMpegSource and DirectShowSource
|
||||||
else {
|
else {
|
||||||
// Try loading FFMpegSource
|
// Try loading FFMpegSource
|
||||||
|
directshowOpen:
|
||||||
bool ffsource = false;
|
bool ffsource = false;
|
||||||
if (env->FunctionExists("ffmpegsource")) ffsource = true;
|
if (env->FunctionExists("ffmpegsource")) ffsource = true;
|
||||||
if (!ffsource) {
|
if (!ffsource) {
|
||||||
|
@ -236,6 +244,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading FFMpegSource"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading FFMpegSource"));
|
||||||
env->Invoke("LoadPlugin",env->SaveString(ffsourcepath.GetFullPath().mb_str(wxConvLocal)));
|
env->Invoke("LoadPlugin",env->SaveString(ffsourcepath.GetFullPath().mb_str(wxConvLocal)));
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loaded FFMpegSource"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loaded FFMpegSource"));
|
||||||
|
byFrame = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +259,6 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
|
||||||
|
|
||||||
// DirectShowSource
|
// DirectShowSource
|
||||||
if (!ffsource) {
|
if (!ffsource) {
|
||||||
directshowOpen:
|
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening file with DirectShowSource"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening file with DirectShowSource"));
|
||||||
|
|
||||||
// Try loading DirectShowSource2
|
// Try loading DirectShowSource2
|
||||||
|
@ -293,7 +301,7 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
|
||||||
script = env->Invoke("DirectShowSource", AVSValue(args,4), argnames);
|
script = env->Invoke("DirectShowSource", AVSValue(args,4), argnames);
|
||||||
}
|
}
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with DSS without audio"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with DSS without audio"));
|
||||||
usedDirectshow = true;
|
usedDirectShow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Failed to find a suitable function
|
// 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"));
|
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
|
// Cache
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Finished opening video, AVS mutex will be released now"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Finished opening video, AVS mutex will be released now"));
|
||||||
return (env->Invoke("Cache", script)).AsClip();
|
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
|
#endif
|
||||||
|
|
|
@ -110,6 +110,7 @@ public:
|
||||||
int GetWidth();
|
int GetWidth();
|
||||||
int GetHeight();
|
int GetHeight();
|
||||||
double GetFPS();
|
double GetFPS();
|
||||||
|
bool IsNativelyByFrames() { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue