mirror of https://github.com/odrling/Aegisub
Write the video's colorspace to the script info section
Originally committed to SVN as r6347.
This commit is contained in:
parent
f2aadc7439
commit
3b5bc88285
|
@ -64,6 +64,10 @@ public:
|
||||||
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
|
||||||
|
|
||||||
|
/// Get the source colorspace of the video before it was converted to RGB
|
||||||
|
/// @return A string describing the source colorspace or empty if it is
|
||||||
|
/// unknown or meaningless
|
||||||
|
virtual wxString GetColorSpace() const { return ""; }
|
||||||
|
|
||||||
/// @brief Use this to set any post-loading warnings, such as "being loaded with unreliable seeking"
|
/// @brief Use this to set any post-loading warnings, such as "being loaded with unreliable seeking"
|
||||||
virtual wxString GetWarning() const { return ""; }
|
virtual wxString GetWarning() const { return ""; }
|
||||||
|
|
|
@ -252,6 +252,7 @@ void VideoContext::OnSubtitlesCommit() {
|
||||||
void VideoContext::OnSubtitlesSave() {
|
void VideoContext::OnSubtitlesSave() {
|
||||||
if (!IsLoaded()) {
|
if (!IsLoaded()) {
|
||||||
context->ass->SetScriptInfo("Video File", "");
|
context->ass->SetScriptInfo("Video File", "");
|
||||||
|
context->ass->SetScriptInfo("Video Colorspace", "");
|
||||||
context->ass->SetScriptInfo("Video Aspect Ratio", "");
|
context->ass->SetScriptInfo("Video Aspect Ratio", "");
|
||||||
context->ass->SetScriptInfo("Video Position", "");
|
context->ass->SetScriptInfo("Video Position", "");
|
||||||
context->ass->SetScriptInfo("VFR File", "");
|
context->ass->SetScriptInfo("VFR File", "");
|
||||||
|
@ -266,6 +267,7 @@ void VideoContext::OnSubtitlesSave() {
|
||||||
ar = wxString::Format("%d", arType);
|
ar = wxString::Format("%d", arType);
|
||||||
|
|
||||||
context->ass->SetScriptInfo("Video File", MakeRelativePath(videoFile, context->ass->filename));
|
context->ass->SetScriptInfo("Video File", MakeRelativePath(videoFile, context->ass->filename));
|
||||||
|
context->ass->SetScriptInfo("Video Colorspace", videoProvider->GetColorSpace());
|
||||||
context->ass->SetScriptInfo("Video Aspect Ratio", ar);
|
context->ass->SetScriptInfo("Video Aspect Ratio", ar);
|
||||||
context->ass->SetScriptInfo("Video Position", wxString::Format("%d", frame_n));
|
context->ass->SetScriptInfo("Video Position", wxString::Format("%d", frame_n));
|
||||||
context->ass->SetScriptInfo("VFR File", MakeRelativePath(GetTimecodesName(), context->ass->filename));
|
context->ass->SetScriptInfo("VFR File", MakeRelativePath(GetTimecodesName(), context->ass->filename));
|
||||||
|
|
|
@ -71,12 +71,13 @@ public:
|
||||||
virtual ~VideoProviderCache();
|
virtual ~VideoProviderCache();
|
||||||
|
|
||||||
// Override the following methods:
|
// Override the following methods:
|
||||||
virtual int GetPosition() const { return master->GetPosition(); }
|
int GetPosition() const { return master->GetPosition(); }
|
||||||
virtual int GetFrameCount() const { return master->GetFrameCount(); }
|
int GetFrameCount() const { return master->GetFrameCount(); }
|
||||||
virtual int GetWidth() const { return master->GetWidth(); }
|
int GetWidth() const { return master->GetWidth(); }
|
||||||
virtual int GetHeight() const { return master->GetHeight(); }
|
int GetHeight() const { return master->GetHeight(); }
|
||||||
virtual agi::vfr::Framerate GetFPS() const { return master->GetFPS(); }
|
agi::vfr::Framerate GetFPS() const { return master->GetFPS(); }
|
||||||
virtual std::vector<int> GetKeyFrames() const { return master->GetKeyFrames(); }
|
std::vector<int> GetKeyFrames() const { return master->GetKeyFrames(); }
|
||||||
virtual wxString GetWarning() const { return master->GetWarning(); }
|
wxString GetWarning() const { return master->GetWarning(); }
|
||||||
virtual wxString GetDecoderName() const { return master->GetDecoderName(); }
|
wxString GetDecoderName() const { return master->GetDecoderName(); }
|
||||||
|
wxString GetColorSpace() const { return master->GetColorSpace(); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -223,6 +223,14 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) {
|
||||||
Width = TempFrame->EncodedWidth;
|
Width = TempFrame->EncodedWidth;
|
||||||
Height = TempFrame->EncodedHeight;
|
Height = TempFrame->EncodedHeight;
|
||||||
|
|
||||||
|
switch (TempFrame->ColorSpace) {
|
||||||
|
case FFMS_CS_RGB: ColorSpace = "RGB"; break;
|
||||||
|
case FFMS_CS_BT709: ColorSpace = "BT.709"; break;
|
||||||
|
case FFMS_CS_BT470BG: ColorSpace = "BT.601"; break;
|
||||||
|
case FFMS_CS_UNSPECIFIED: ColorSpace = Width > 1024 || Height >= 600 ? "BT.709" : "BT.601"; break;
|
||||||
|
default: ColorSpace = ""; break;
|
||||||
|
}
|
||||||
|
|
||||||
#if FFMS_VERSION >= ((2 << 24) | (15 << 16) | (3 << 8) | 0)
|
#if FFMS_VERSION >= ((2 << 24) | (15 << 16) | (3 << 8) | 0)
|
||||||
const int TargetFormat[] = { FFMS_GetPixFmt("bgra"), -1 };
|
const int TargetFormat[] = { FFMS_GetPixFmt("bgra"), -1 };
|
||||||
if (FFMS_SetOutputFormatV2(VideoSource, TargetFormat, Width, Height, FFMS_RESIZER_BICUBIC, &ErrInfo)) {
|
if (FFMS_SetOutputFormatV2(VideoSource, TargetFormat, Width, Height, FFMS_RESIZER_BICUBIC, &ErrInfo)) {
|
||||||
|
@ -266,8 +274,6 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) {
|
||||||
FrameNumber = 0;
|
FrameNumber = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Close video
|
|
||||||
///
|
|
||||||
void FFmpegSourceVideoProvider::Close() {
|
void FFmpegSourceVideoProvider::Close() {
|
||||||
if (VideoSource) FFMS_DestroyVideoSource(VideoSource);
|
if (VideoSource) FFMS_DestroyVideoSource(VideoSource);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -276,10 +282,6 @@ void FFmpegSourceVideoProvider::Close() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Get frame
|
|
||||||
/// @param _n
|
|
||||||
/// @return
|
|
||||||
///
|
|
||||||
const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int n) {
|
const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int n) {
|
||||||
FrameNumber = mid(0, n, GetFrameCount() - 1);
|
FrameNumber = mid(0, n, GetFrameCount() - 1);
|
||||||
|
|
||||||
|
@ -292,4 +294,5 @@ const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int n) {
|
||||||
CurFrame.SetTo(SrcFrame->Data[0], Width, Height, SrcFrame->Linesize[0]);
|
CurFrame.SetTo(SrcFrame->Data[0], Width, Height, SrcFrame->Linesize[0]);
|
||||||
return CurFrame;
|
return CurFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WITH_FFMS2 */
|
#endif /* WITH_FFMS2 */
|
||||||
|
|
|
@ -46,21 +46,21 @@
|
||||||
/// @class FFmpegSourceVideoProvider
|
/// @class FFmpegSourceVideoProvider
|
||||||
/// @brief Implements video loading through the FFMS library.
|
/// @brief Implements video loading through the FFMS library.
|
||||||
class FFmpegSourceVideoProvider : public VideoProvider, FFmpegSourceProvider {
|
class FFmpegSourceVideoProvider : public VideoProvider, FFmpegSourceProvider {
|
||||||
private:
|
FFMS_VideoSource *VideoSource; ///< video source object
|
||||||
FFMS_VideoSource *VideoSource; /// video source object
|
const FFMS_VideoProperties *VideoInfo; ///< video properties
|
||||||
const FFMS_VideoProperties *VideoInfo; /// video properties
|
|
||||||
|
|
||||||
int Width; /// width in pixels
|
int Width; ///< width in pixels
|
||||||
int Height; /// height in pixels
|
int Height; ///< height in pixels
|
||||||
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
|
||||||
bool COMInited; /// COM initialization state
|
bool COMInited; ///< COM initialization state
|
||||||
|
wxString ColorSpace; ///< Colorspace name
|
||||||
AegiVideoFrame CurFrame; /// current video frame
|
|
||||||
|
AegiVideoFrame CurFrame; ///< current video frame
|
||||||
char FFMSErrMsg[1024]; /// FFMS error message
|
|
||||||
FFMS_ErrorInfo ErrInfo; /// FFMS error codes/messages
|
char FFMSErrMsg[1024]; ///< FFMS error message
|
||||||
|
FFMS_ErrorInfo ErrInfo; ///< FFMS error codes/messages
|
||||||
|
|
||||||
void LoadVideo(wxString filename);
|
void LoadVideo(wxString filename);
|
||||||
void Close();
|
void Close();
|
||||||
|
@ -77,6 +77,8 @@ public:
|
||||||
int GetHeight() const { return Height; }
|
int GetHeight() const { return Height; }
|
||||||
agi::vfr::Framerate GetFPS() const { return Timecodes; }
|
agi::vfr::Framerate GetFPS() const { return Timecodes; }
|
||||||
|
|
||||||
|
wxString GetColorSpace() const { return ColorSpace; }
|
||||||
|
|
||||||
/// @brief Gets a list of keyframes
|
/// @brief Gets a list of keyframes
|
||||||
/// @return Returns a wxArrayInt of keyframes.
|
/// @return Returns a wxArrayInt of keyframes.
|
||||||
std::vector<int> GetKeyFrames() const { return KeyFramesList; };
|
std::vector<int> GetKeyFrames() const { return KeyFramesList; };
|
||||||
|
|
Loading…
Reference in New Issue