forked from mia/Aegisub
Made Avisynth video provider use FFMpegSource for non avi/d2v/avs, but it will break for vfr because of the hack to make it work with dss
Originally committed to SVN as r1227.
This commit is contained in:
parent
354f96c081
commit
34cd74525d
1 changed files with 65 additions and 41 deletions
|
@ -225,58 +225,82 @@ PClip AvisynthVideoProvider::OpenVideo(wxString _filename, bool mpeg2dec3_priori
|
||||||
script = env->Invoke("SetPlanarLegacyAlignment", script);
|
script = env->Invoke("SetPlanarLegacyAlignment", script);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some other format, such as mkv, mp4, ogm... try DirectShowSource
|
// Some other format, such as mkv, mp4, ogm... try FFMpegSource and DirectShowSource
|
||||||
else {
|
else {
|
||||||
directshowOpen:
|
// Try loading FFMpegSource
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening file with DirectShowSource"));
|
bool ffsource = false;
|
||||||
|
if (env->FunctionExists("ffmpegsource")) ffsource = true;
|
||||||
// Try loading DirectShowSource2
|
if (!ffsource) {
|
||||||
bool dss2 = false;
|
wxFileName ffsourcepath(AegisubApp::folderName + _T("ffmpegsource.dll"));
|
||||||
if (env->FunctionExists("dss2")) dss2 = true;
|
if (ffsourcepath.FileExists()) {
|
||||||
if (!dss2) {
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading FFMpegSource"));
|
||||||
wxFileName dss2path(AegisubApp::folderName + _T("avss.dll"));
|
env->Invoke("LoadPlugin",env->SaveString(ffsourcepath.GetFullPath().mb_str(wxConvLocal)));
|
||||||
if (dss2path.FileExists()) {
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loaded FFMpegSource"));
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading DirectShowSource2"));
|
|
||||||
env->Invoke("LoadPlugin",env->SaveString(dss2path.GetFullPath().mb_str(wxConvLocal)));
|
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loaded DirectShowSource2"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If DSS2 loaded properly, try using it
|
// If FFMpegSource loaded properly, try using it
|
||||||
dss2 = false;
|
ffsource = false;
|
||||||
if (env->FunctionExists("dss2")) {
|
if (env->FunctionExists("ffmpegsource")) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Invoking DSS2"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Invoking FFMpegSource"));
|
||||||
if (fps == 0.0) script = env->Invoke("DSS2", videoFilename);
|
script = env->Invoke("ffmpegsource", videoFilename);
|
||||||
else {
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with FFMpegSource"));
|
||||||
const char *argnames[2] = { 0, "fps" };
|
ffsource = true;
|
||||||
AVSValue args[2] = { videoFilename, fps };
|
|
||||||
script = env->Invoke("DSS2", AVSValue(args,2), argnames);
|
|
||||||
}
|
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with DSS2"));
|
|
||||||
dss2 = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try DirectShowSource
|
// DirectShowSource
|
||||||
if (!dss2) {
|
if (!ffsource) {
|
||||||
if (env->FunctionExists("DirectShowSource")) {
|
directshowOpen:
|
||||||
if (fps == 0.0) {
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Opening file with DirectShowSource"));
|
||||||
const char *argnames[3] = { 0, "video", "audio" };
|
|
||||||
AVSValue args[3] = { videoFilename, true, false };
|
// Try loading DirectShowSource2
|
||||||
script = env->Invoke("DirectShowSource", AVSValue(args,3), argnames);
|
bool dss2 = false;
|
||||||
|
if (env->FunctionExists("dss2")) dss2 = true;
|
||||||
|
if (!dss2) {
|
||||||
|
wxFileName dss2path(AegisubApp::folderName + _T("avss.dll"));
|
||||||
|
if (dss2path.FileExists()) {
|
||||||
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loading DirectShowSource2"));
|
||||||
|
env->Invoke("LoadPlugin",env->SaveString(dss2path.GetFullPath().mb_str(wxConvLocal)));
|
||||||
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Loaded DirectShowSource2"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If DSS2 loaded properly, try using it
|
||||||
|
dss2 = false;
|
||||||
|
if (env->FunctionExists("dss2")) {
|
||||||
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Invoking DSS2"));
|
||||||
|
if (fps == 0.0) script = env->Invoke("DSS2", videoFilename);
|
||||||
else {
|
else {
|
||||||
const char *argnames[4] = { 0, "video", "audio" , "fps" };
|
const char *argnames[2] = { 0, "fps" };
|
||||||
AVSValue args[4] = { videoFilename, true, false , fps };
|
AVSValue args[2] = { videoFilename, fps };
|
||||||
script = env->Invoke("DirectShowSource", AVSValue(args,4), argnames);
|
script = env->Invoke("DSS2", AVSValue(args,2), argnames);
|
||||||
}
|
}
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with DSS without audio"));
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with DSS2"));
|
||||||
usedDirectshow = true;
|
dss2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Failed to find a suitable function
|
// Try DirectShowSource
|
||||||
else {
|
if (!dss2) {
|
||||||
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: DSS function not found"));
|
if (env->FunctionExists("DirectShowSource")) {
|
||||||
throw AvisynthError("No function suitable for opening the video found");
|
if (fps == 0.0) {
|
||||||
|
const char *argnames[3] = { 0, "video", "audio" };
|
||||||
|
AVSValue args[3] = { videoFilename, true, false };
|
||||||
|
script = env->Invoke("DirectShowSource", AVSValue(args,3), argnames);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const char *argnames[4] = { 0, "video", "audio" , "fps" };
|
||||||
|
AVSValue args[4] = { videoFilename, true, false , fps };
|
||||||
|
script = env->Invoke("DirectShowSource", AVSValue(args,4), argnames);
|
||||||
|
}
|
||||||
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: Successfully opened file with DSS without audio"));
|
||||||
|
usedDirectshow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failed to find a suitable function
|
||||||
|
else {
|
||||||
|
AVSTRACE(_T("AvisynthVideoProvider::OpenVideo: DSS function not found"));
|
||||||
|
throw AvisynthError("No function suitable for opening the video found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue