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
5 changed files with 40 additions and 28 deletions
|
@ -64,6 +64,10 @@ public:
|
|||
virtual agi::vfr::Framerate GetFPS() const=0; ///< Get frame rate
|
||||
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"
|
||||
virtual wxString GetWarning() const { return ""; }
|
||||
|
|
|
@ -252,6 +252,7 @@ void VideoContext::OnSubtitlesCommit() {
|
|||
void VideoContext::OnSubtitlesSave() {
|
||||
if (!IsLoaded()) {
|
||||
context->ass->SetScriptInfo("Video File", "");
|
||||
context->ass->SetScriptInfo("Video Colorspace", "");
|
||||
context->ass->SetScriptInfo("Video Aspect Ratio", "");
|
||||
context->ass->SetScriptInfo("Video Position", "");
|
||||
context->ass->SetScriptInfo("VFR File", "");
|
||||
|
@ -266,6 +267,7 @@ void VideoContext::OnSubtitlesSave() {
|
|||
ar = wxString::Format("%d", arType);
|
||||
|
||||
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 Position", wxString::Format("%d", frame_n));
|
||||
context->ass->SetScriptInfo("VFR File", MakeRelativePath(GetTimecodesName(), context->ass->filename));
|
||||
|
|
|
@ -71,12 +71,13 @@ public:
|
|||
virtual ~VideoProviderCache();
|
||||
|
||||
// Override the following methods:
|
||||
virtual int GetPosition() const { return master->GetPosition(); }
|
||||
virtual int GetFrameCount() const { return master->GetFrameCount(); }
|
||||
virtual int GetWidth() const { return master->GetWidth(); }
|
||||
virtual int GetHeight() const { return master->GetHeight(); }
|
||||
virtual agi::vfr::Framerate GetFPS() const { return master->GetFPS(); }
|
||||
virtual std::vector<int> GetKeyFrames() const { return master->GetKeyFrames(); }
|
||||
virtual wxString GetWarning() const { return master->GetWarning(); }
|
||||
virtual wxString GetDecoderName() const { return master->GetDecoderName(); }
|
||||
int GetPosition() const { return master->GetPosition(); }
|
||||
int GetFrameCount() const { return master->GetFrameCount(); }
|
||||
int GetWidth() const { return master->GetWidth(); }
|
||||
int GetHeight() const { return master->GetHeight(); }
|
||||
agi::vfr::Framerate GetFPS() const { return master->GetFPS(); }
|
||||
std::vector<int> GetKeyFrames() const { return master->GetKeyFrames(); }
|
||||
wxString GetWarning() const { return master->GetWarning(); }
|
||||
wxString GetDecoderName() const { return master->GetDecoderName(); }
|
||||
wxString GetColorSpace() const { return master->GetColorSpace(); }
|
||||
};
|
||||
|
|
|
@ -223,6 +223,14 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) {
|
|||
Width = TempFrame->EncodedWidth;
|
||||
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)
|
||||
const int TargetFormat[] = { FFMS_GetPixFmt("bgra"), -1 };
|
||||
if (FFMS_SetOutputFormatV2(VideoSource, TargetFormat, Width, Height, FFMS_RESIZER_BICUBIC, &ErrInfo)) {
|
||||
|
@ -266,8 +274,6 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) {
|
|||
FrameNumber = 0;
|
||||
}
|
||||
|
||||
/// @brief Close video
|
||||
///
|
||||
void FFmpegSourceVideoProvider::Close() {
|
||||
if (VideoSource) FFMS_DestroyVideoSource(VideoSource);
|
||||
#ifdef WIN32
|
||||
|
@ -276,10 +282,6 @@ void FFmpegSourceVideoProvider::Close() {
|
|||
#endif
|
||||
}
|
||||
|
||||
/// @brief Get frame
|
||||
/// @param _n
|
||||
/// @return
|
||||
///
|
||||
const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int n) {
|
||||
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]);
|
||||
return CurFrame;
|
||||
}
|
||||
|
||||
#endif /* WITH_FFMS2 */
|
||||
|
|
|
@ -46,21 +46,21 @@
|
|||
/// @class FFmpegSourceVideoProvider
|
||||
/// @brief Implements video loading through the FFMS library.
|
||||
class FFmpegSourceVideoProvider : public VideoProvider, FFmpegSourceProvider {
|
||||
private:
|
||||
FFMS_VideoSource *VideoSource; /// video source object
|
||||
const FFMS_VideoProperties *VideoInfo; /// video properties
|
||||
FFMS_VideoSource *VideoSource; ///< video source object
|
||||
const FFMS_VideoProperties *VideoInfo; ///< video properties
|
||||
|
||||
int Width; /// width in pixels
|
||||
int Height; /// height in pixels
|
||||
int FrameNumber; /// current framenumber
|
||||
std::vector<int> KeyFramesList; /// list of keyframes
|
||||
agi::vfr::Framerate Timecodes; /// vfr object
|
||||
bool COMInited; /// COM initialization state
|
||||
|
||||
AegiVideoFrame CurFrame; /// current video frame
|
||||
|
||||
char FFMSErrMsg[1024]; /// FFMS error message
|
||||
FFMS_ErrorInfo ErrInfo; /// FFMS error codes/messages
|
||||
int Width; ///< width in pixels
|
||||
int Height; ///< height in pixels
|
||||
int FrameNumber; ///< current framenumber
|
||||
std::vector<int> KeyFramesList; ///< list of keyframes
|
||||
agi::vfr::Framerate Timecodes; ///< vfr object
|
||||
bool COMInited; ///< COM initialization state
|
||||
wxString ColorSpace; ///< Colorspace name
|
||||
|
||||
AegiVideoFrame CurFrame; ///< current video frame
|
||||
|
||||
char FFMSErrMsg[1024]; ///< FFMS error message
|
||||
FFMS_ErrorInfo ErrInfo; ///< FFMS error codes/messages
|
||||
|
||||
void LoadVideo(wxString filename);
|
||||
void Close();
|
||||
|
@ -77,6 +77,8 @@ public:
|
|||
int GetHeight() const { return Height; }
|
||||
agi::vfr::Framerate GetFPS() const { return Timecodes; }
|
||||
|
||||
wxString GetColorSpace() const { return ColorSpace; }
|
||||
|
||||
/// @brief Gets a list of keyframes
|
||||
/// @return Returns a wxArrayInt of keyframes.
|
||||
std::vector<int> GetKeyFrames() const { return KeyFramesList; };
|
||||
|
|
Loading…
Reference in a new issue