diff --git a/aegisub/video_provider_ffmpegsource.cpp b/aegisub/video_provider_ffmpegsource.cpp index da3001000..48699bdbd 100644 --- a/aegisub/video_provider_ffmpegsource.cpp +++ b/aegisub/video_provider_ffmpegsource.cpp @@ -157,6 +157,9 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps) VFR_Input.SetVFR(TimecodesVector); VFR_Output.SetVFR(TimecodesVector); } + } else { // no timecodes loaded, go ahead and apply + VFR_Input.SetVFR(TimecodesVector); + VFR_Output.SetVFR(TimecodesVector); } // we don't need this anymore @@ -188,16 +191,22 @@ void FFmpegSourceVideoProvider::Close() { /////////////// // Get frame -const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int n, int FormatType) { +const AegiVideoFrame FFmpegSourceVideoProvider::GetFrame(int _n, int FormatType) { + // don't try to seek to insane places + int n = _n; + if (n < 0) + n = 0; + if (n >= GetFrameCount()) + n = GetFrameCount()-1; + // set position + FrameNumber = n; + const AVFrameLite *SrcFrame = FFMS_GetFrame(VideoSource, n, FFMSErrorMessage, MessageSize); if (SrcFrame == NULL) { ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage); throw ErrorMsg; } - // set position - FrameNumber = n; - AVPicture *SrcPicture = reinterpret_cast(const_cast(SrcFrame)); // prepare stuff for conversion to RGB32 diff --git a/aegisub/video_provider_ffmpegsource.h b/aegisub/video_provider_ffmpegsource.h index d66e5ee7f..0ef01c5de 100644 --- a/aegisub/video_provider_ffmpegsource.h +++ b/aegisub/video_provider_ffmpegsource.h @@ -94,7 +94,7 @@ public: bool AreKeyFramesLoaded() { return KeyFramesLoaded; }; wxArrayInt GetKeyFrames() { return KeyFramesList; }; bool IsVFR() { return true; }; - FrameRate GetTrueFrameRate() { return FrameRate(); }; + FrameRate GetTrueFrameRate() { return Timecodes; }; Aegisub::String GetDecoderName() { return L"FFmpegSource"; } bool IsNativelyByFrames() { return true; } int GetDesiredCacheSize() { return 8; }