Implement timestamp reading from the container in the ffmpeg video provider. Updates #864.
Originally committed to SVN as r3083.
This commit is contained in:
parent
06ff786c60
commit
2e9439c9f5
2 changed files with 22 additions and 2 deletions
|
@ -137,6 +137,25 @@ void LAVCVideoProvider::LoadVideo(Aegisub::String filename, double fps) {
|
|||
length = LAVCFrameData.GetNumFrames();
|
||||
framesData = LAVCFrameData.GetFrameData();
|
||||
|
||||
std::vector<int> timecodesVector;
|
||||
for (int i = 0; i < length; i++) {
|
||||
int timestamp = (int)((framesData[i].DTS * (int64_t)lavcfile->fctx->streams[vidStream]->time_base.num * 1000)
|
||||
/ (int64_t)lavcfile->fctx->streams[vidStream]->time_base.den);
|
||||
timecodesVector.push_back(timestamp);
|
||||
}
|
||||
timecodes.SetVFR(timecodesVector);
|
||||
int OverrideTC = wxYES;
|
||||
if (VFR_Output.IsLoaded()) {
|
||||
OverrideTC = wxMessageBox(_("You already have timecodes loaded. Would you like to replace them with timecodes from the video file?"), _("Replace timecodes?"), wxYES_NO | wxICON_QUESTION);
|
||||
if (OverrideTC == wxYES) {
|
||||
VFR_Input.SetVFR(timecodesVector);
|
||||
VFR_Output.SetVFR(timecodesVector);
|
||||
}
|
||||
} else { // no timecodes loaded, go ahead and apply
|
||||
VFR_Input.SetVFR(timecodesVector);
|
||||
VFR_Output.SetVFR(timecodesVector);
|
||||
}
|
||||
|
||||
// Allocate frame
|
||||
frame = avcodec_alloc_frame();
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ private:
|
|||
AegiVideoFrame curFrame;
|
||||
bool validFrame;
|
||||
LAVCFrameInfoVector framesData;
|
||||
FrameRate timecodes;
|
||||
|
||||
uint8_t *buffer1;
|
||||
uint8_t *buffer2;
|
||||
|
@ -119,8 +120,8 @@ public:
|
|||
double GetFPS();
|
||||
bool AreKeyFramesLoaded() { return keyFramesLoaded; };
|
||||
wxArrayInt GetKeyFrames() { return KeyFramesList; };
|
||||
bool IsVFR() { return false; }; // FIXME: bork?
|
||||
FrameRate GetTrueFrameRate() { return FrameRate(); }; // nothing useful here
|
||||
bool IsVFR() { return true; };
|
||||
FrameRate GetTrueFrameRate() { return timecodes; };
|
||||
Aegisub::String GetDecoderName() { return L"FFMpeg/libavcodec"; }
|
||||
bool IsNativelyByFrames() { return true; }
|
||||
int GetDesiredCacheSize() { return 8; }
|
||||
|
|
Loading…
Reference in a new issue