mirror of https://github.com/odrling/Aegisub
Automatically set the aspect ratio when opening anamorphic video with ffms
Originally committed to SVN as r6506.
This commit is contained in:
parent
7e87e95526
commit
ea130d9af2
|
@ -60,6 +60,7 @@ public:
|
||||||
virtual int GetFrameCount() const=0; ///< Get total number of frames
|
virtual int GetFrameCount() const=0; ///< Get total number of frames
|
||||||
virtual int GetWidth() const=0; ///< Returns the video width in pixels
|
virtual int GetWidth() const=0; ///< Returns the video width in pixels
|
||||||
virtual int GetHeight() const=0; ///< Returns the video height in pixels
|
virtual int GetHeight() const=0; ///< Returns the video height in pixels
|
||||||
|
virtual double GetDAR() const=0; ///< Returns the video display aspect ratio
|
||||||
virtual agi::vfr::Framerate GetFPS() const=0; ///< Get frame rate
|
virtual agi::vfr::Framerate GetFPS() const=0; ///< Get frame rate
|
||||||
virtual std::vector<int> GetKeyFrames() const=0;///< Returns list of keyframes
|
virtual std::vector<int> GetKeyFrames() const=0;///< Returns list of keyframes
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,11 @@ void VideoContext::SetVideo(const wxString &filename) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set aspect ratio
|
||||||
|
double dar = videoProvider->GetDAR();
|
||||||
|
if (dar > 0)
|
||||||
|
SetAspectRatio(4, dar);
|
||||||
|
|
||||||
// Set filename
|
// Set filename
|
||||||
config::mru->Add("Video", STD_STR(filename));
|
config::mru->Add("Video", STD_STR(filename));
|
||||||
StandardPaths::SetPathValue("?video", wxFileName(filename).GetPath());
|
StandardPaths::SetPathValue("?video", wxFileName(filename).GetPath());
|
||||||
|
|
|
@ -70,6 +70,7 @@ public:
|
||||||
agi::vfr::Framerate GetFPS() const { return fps; };
|
agi::vfr::Framerate GetFPS() const { return fps; };
|
||||||
int GetWidth() const { return vi.width; };
|
int GetWidth() const { return vi.width; };
|
||||||
int GetHeight() const { return vi.height; };
|
int GetHeight() const { return vi.height; };
|
||||||
|
double GetDAR() const { return 0; }
|
||||||
std::vector<int> GetKeyFrames() const { return KeyFrames; };
|
std::vector<int> GetKeyFrames() const { return KeyFrames; };
|
||||||
wxString GetWarning() const { return warning; }
|
wxString GetWarning() const { return warning; }
|
||||||
wxString GetDecoderName() const { return decoderName; }
|
wxString GetDecoderName() const { return decoderName; }
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
int GetFrameCount() const { return master->GetFrameCount(); }
|
int GetFrameCount() const { return master->GetFrameCount(); }
|
||||||
int GetWidth() const { return master->GetWidth(); }
|
int GetWidth() const { return master->GetWidth(); }
|
||||||
int GetHeight() const { return master->GetHeight(); }
|
int GetHeight() const { return master->GetHeight(); }
|
||||||
|
double GetDAR() const { return master->GetDAR(); }
|
||||||
agi::vfr::Framerate GetFPS() const { return master->GetFPS(); }
|
agi::vfr::Framerate GetFPS() const { return master->GetFPS(); }
|
||||||
std::vector<int> GetKeyFrames() const { return master->GetKeyFrames(); }
|
std::vector<int> GetKeyFrames() const { return master->GetKeyFrames(); }
|
||||||
wxString GetWarning() const { return master->GetWarning(); }
|
wxString GetWarning() const { return master->GetWarning(); }
|
||||||
|
|
|
@ -88,6 +88,7 @@ public:
|
||||||
int GetFrameCount() const { return framecount; }
|
int GetFrameCount() const { return framecount; }
|
||||||
int GetWidth() const { return width; }
|
int GetWidth() const { return width; }
|
||||||
int GetHeight() const { return height; }
|
int GetHeight() const { return height; }
|
||||||
|
double GetDAR() const { return 0; }
|
||||||
agi::vfr::Framerate GetFPS() const { return fps; }
|
agi::vfr::Framerate GetFPS() const { return fps; }
|
||||||
std::vector<int> GetKeyFrames() const { return std::vector<int>(); };
|
std::vector<int> GetKeyFrames() const { return std::vector<int>(); };
|
||||||
wxString GetDecoderName() const { return "Dummy Video Provider"; }
|
wxString GetDecoderName() const { return "Dummy Video Provider"; }
|
||||||
|
|
|
@ -167,11 +167,15 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) {
|
||||||
VideoInfo = FFMS_GetVideoProperties(VideoSource);
|
VideoInfo = FFMS_GetVideoProperties(VideoSource);
|
||||||
|
|
||||||
const FFMS_Frame *TempFrame = FFMS_GetFrame(VideoSource, 0, &ErrInfo);
|
const FFMS_Frame *TempFrame = FFMS_GetFrame(VideoSource, 0, &ErrInfo);
|
||||||
if (TempFrame == NULL) {
|
if (!TempFrame)
|
||||||
throw VideoOpenError(std::string("Failed to decode first frame: ") + ErrInfo.Buffer);
|
throw VideoOpenError(std::string("Failed to decode first frame: ") + ErrInfo.Buffer);
|
||||||
}
|
|
||||||
Width = TempFrame->EncodedWidth;
|
Width = TempFrame->EncodedWidth;
|
||||||
Height = TempFrame->EncodedHeight;
|
Height = TempFrame->EncodedHeight;
|
||||||
|
if (VideoInfo->SARDen > 0 && VideoInfo->SARNum > 0)
|
||||||
|
DAR = double(Width * VideoInfo->SARNum) / (Height * VideoInfo->SARDen);
|
||||||
|
else
|
||||||
|
DAR = double(Width) / Height;
|
||||||
|
|
||||||
switch (TempFrame->ColorSpace) {
|
switch (TempFrame->ColorSpace) {
|
||||||
case FFMS_CS_RGB: ColorSpace = "RGB"; break;
|
case FFMS_CS_RGB: ColorSpace = "RGB"; break;
|
||||||
|
|
|
@ -52,6 +52,7 @@ class FFmpegSourceVideoProvider : public VideoProvider, FFmpegSourceProvider {
|
||||||
|
|
||||||
int Width; ///< width in pixels
|
int Width; ///< width in pixels
|
||||||
int Height; ///< height in pixels
|
int Height; ///< height in pixels
|
||||||
|
double DAR; ///< display aspect ratio
|
||||||
int FrameNumber; ///< current framenumber
|
int FrameNumber; ///< current framenumber
|
||||||
std::vector<int> KeyFramesList; ///< list of keyframes
|
std::vector<int> KeyFramesList; ///< list of keyframes
|
||||||
agi::vfr::Framerate Timecodes; ///< vfr object
|
agi::vfr::Framerate Timecodes; ///< vfr object
|
||||||
|
@ -72,6 +73,7 @@ public:
|
||||||
int GetFrameCount() const { return VideoInfo->NumFrames; }
|
int GetFrameCount() const { return VideoInfo->NumFrames; }
|
||||||
int GetWidth() const { return Width; }
|
int GetWidth() const { return Width; }
|
||||||
int GetHeight() const { return Height; }
|
int GetHeight() const { return Height; }
|
||||||
|
double GetDAR() const { return DAR; }
|
||||||
agi::vfr::Framerate GetFPS() const { return Timecodes; }
|
agi::vfr::Framerate GetFPS() const { return Timecodes; }
|
||||||
|
|
||||||
wxString GetColorSpace() const { return ColorSpace; }
|
wxString GetColorSpace() const { return ColorSpace; }
|
||||||
|
|
|
@ -146,6 +146,7 @@ public:
|
||||||
int GetFrameCount() const { return num_frames; }
|
int GetFrameCount() const { return num_frames; }
|
||||||
int GetWidth() const { return w; }
|
int GetWidth() const { return w; }
|
||||||
int GetHeight() const { return h; }
|
int GetHeight() const { return h; }
|
||||||
|
double GetDAR() const { return 0; }
|
||||||
agi::vfr::Framerate GetFPS() const { return fps; }
|
agi::vfr::Framerate GetFPS() const { return fps; }
|
||||||
std::vector<int> GetKeyFrames() const { return std::vector<int>(); };
|
std::vector<int> GetKeyFrames() const { return std::vector<int>(); };
|
||||||
wxString GetDecoderName() const { return "YU4MPEG"; };
|
wxString GetDecoderName() const { return "YU4MPEG"; };
|
||||||
|
|
Loading…
Reference in New Issue