exporttask: snap to timebase when exporting video

This is a bit of a hack to prevent #2119 from causing problems. The reality is this probably requires a deeper re-think of how the timeline should and shouldn't work - this issue is more of a symptom of something deeper than a simple bug in and of itself.
This commit is contained in:
itsmattkc
2023-02-01 00:40:06 -08:00
parent c7841a92a2
commit aa6b77f800
2 changed files with 13 additions and 17 deletions
+11 -17
View File
@@ -51,8 +51,6 @@ ExportTask::ExportTask(ViewerOutput *viewer_node,
bool ExportTask::Run()
{
TimeRange range;
// For safety, if we're overwriting, we save to a temporary filename and then only overwrite it
// at the end
QString real_filename = params_.filename();
@@ -111,10 +109,10 @@ bool ExportTask::Run()
if (params_.has_custom_range()) {
// Render custom range only
range = params_.custom_range();
export_range_ = params_.custom_range();
} else {
// Render entire sequence
range = TimeRange(0, viewer()->GetLength());
export_range_ = TimeRange(0, viewer()->GetLength());
}
frame_time_ = 0;
@@ -152,15 +150,19 @@ bool ExportTask::Run()
TimeRange subtitle_range;
if (params_.video_enabled()) {
video_range = {range};
if (export_range_.in() > 0) {
export_range_.set_in(Timecode::snap_time_to_timebase(export_range_.in(), video_params().frame_rate_as_time_base()));
}
video_range = {export_range_};
}
if (params_.audio_enabled()) {
audio_range = {range};
audio_range = {export_range_};
}
if (subtitles_enabled) {
subtitle_range = range;
subtitle_range = export_range_;
}
Render(color_manager_, video_range, audio_range, subtitle_range, RenderMode::kOnline, nullptr,
@@ -201,11 +203,7 @@ bool ExportTask::Run()
bool ExportTask::FrameDownloaded(FramePtr f, const rational &time)
{
rational actual_time = time;
if (params_.has_custom_range()) {
actual_time -= params_.custom_range().in();
}
rational actual_time = time - export_range_.in();
time_map_.insert(actual_time, f);
@@ -233,11 +231,7 @@ bool ExportTask::FrameDownloaded(FramePtr f, const rational &time)
bool ExportTask::AudioDownloaded(const TimeRange &range, const SampleBuffer &samples)
{
TimeRange adjusted_range = range;
if (params_.has_custom_range()) {
adjusted_range -= params_.custom_range().in();
}
TimeRange adjusted_range = range - export_range_.in();
if (adjusted_range.in() == audio_time_) {
if (!WriteAudioLoop(adjusted_range, samples)) {
+2
View File
@@ -73,6 +73,8 @@ private:
rational audio_time_;
TimeRange export_range_;
};
}