From a70feb5b0b3ff4ae4b984a78c2747a8b54cc7306 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 6 Jan 2019 20:26:10 +1100 Subject: [PATCH] finalized media frame rate change --- dialogs/mediapropertiesdialog.cpp | 20 ++++++++++++++++++++ dialogs/mediapropertiesdialog.h | 12 +++++++----- io/exportthread.cpp | 2 +- project/undo.cpp | 23 +++++++++++++++++++++++ project/undo.h | 9 +++++++++ ui/timelinewidget.cpp | 4 ++++ 6 files changed, 64 insertions(+), 6 deletions(-) diff --git a/dialogs/mediapropertiesdialog.cpp b/dialogs/mediapropertiesdialog.cpp index ada35aa76..c37db60c2 100644 --- a/dialogs/mediapropertiesdialog.cpp +++ b/dialogs/mediapropertiesdialog.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "project/footage.h" #include "project/media.h" @@ -52,6 +53,16 @@ MediaPropertiesDialog::MediaPropertiesDialog(QWidget *parent, Media *i) : row++; if (f->video_tracks.size() > 0) { + // frame conforming + grid->addWidget(new QLabel("Conform to Frame Rate:"), row, 0); + conform_fr = new QDoubleSpinBox(); + conform_fr->setMinimum(0.01); + conform_fr->setValue(f->video_tracks.at(0).video_frame_rate * f->speed); + grid->addWidget(conform_fr, row, 1); + + row++; + + // deinterlacing mode interlacing_box = new QComboBox(); interlacing_box->addItem("Auto (" + get_interlacing_name(f->video_tracks.at(0).video_auto_interlacing) + ")"); interlacing_box->addItem(get_interlacing_name(VIDEO_PROGRESSIVE)); @@ -109,6 +120,8 @@ void MediaPropertiesDialog::accept() { } } + bool refresh_clips = false; + // set interlacing if (f->video_tracks.size() > 0) { if (interlacing_box->currentIndex() > 0) { @@ -116,6 +129,12 @@ void MediaPropertiesDialog::accept() { } else { ca->append(new SetInt(&f->video_tracks[0].video_interlacing, f->video_tracks.at(0).video_auto_interlacing)); } + + // set frame rate conform + if (!qFuzzyCompare(conform_fr->value(), f->video_tracks.at(0).video_frame_rate)) { + ca->append(new SetDouble(&f->speed, f->speed, conform_fr->value()/f->video_tracks.at(0).video_frame_rate)); + refresh_clips = true; + } } // set name @@ -124,6 +143,7 @@ void MediaPropertiesDialog::accept() { ca->append(mr); ca->appendPost(new CloseAllClipsCommand()); ca->appendPost(new UpdateFootageTooltip(item)); + if (refresh_clips) ca->appendPost(new RefreshClips(item)); undo_stack.push(ca); diff --git a/dialogs/mediapropertiesdialog.h b/dialogs/mediapropertiesdialog.h index db173408d..b5699dff7 100644 --- a/dialogs/mediapropertiesdialog.h +++ b/dialogs/mediapropertiesdialog.h @@ -8,18 +8,20 @@ class QComboBox; class QLineEdit; class Media; class QListWidget; +class QDoubleSpinBox; class MediaPropertiesDialog : public QDialog { Q_OBJECT public: - MediaPropertiesDialog(QWidget *parent, Media* i); + MediaPropertiesDialog(QWidget *parent, Media* i); private: QComboBox* interlacing_box; - QLineEdit* name_box; - Media* item; - QListWidget* track_list; + QLineEdit* name_box; + Media* item; + QListWidget* track_list; + QDoubleSpinBox* conform_fr; private slots: - void accept(); + void accept(); }; #endif // MEDIAPROPERTIESDIALOG_H diff --git a/io/exportthread.cpp b/io/exportthread.cpp index b857271e3..a2eeb5962 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -331,7 +331,7 @@ void ExportThread::run() { qint64 start_time, frame_time, avg_time, eta, total_time = 0; long remaining_frames, frame_count = 1; - while (sequence->playhead < end_frame && continueEncode) { + while (sequence->playhead <= end_frame && continueEncode) { start_time = QDateTime::currentMSecsSinceEpoch(); panel_sequence_viewer->viewer_widget->paintGL(); diff --git a/project/undo.cpp b/project/undo.cpp index 81881de44..a169d9d7f 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -1244,3 +1244,26 @@ void SetKeyframing::undo() { void SetKeyframing::redo() { row->setKeyframing(b); } + +RefreshClips::RefreshClips(Media *m) : + media(m) +{} + +void RefreshClips::undo() { + redo(); +} + +void RefreshClips::redo() { + // close any clips currently using this media + QVector all_sequences = panel_project->list_all_project_sequences(); + for (int i=0;ito_sequence(); + for (int j=0;jclips.size();j++) { + Clip* c = s->clips.at(j); + if (c != NULL && c->media == media) { + c->replaced = true; + c->refresh(); + } + } + } +} diff --git a/project/undo.h b/project/undo.h index 4b555746c..ebc7348de 100644 --- a/project/undo.h +++ b/project/undo.h @@ -633,4 +633,13 @@ private: bool b; }; +class RefreshClips : public QUndoCommand { +public: + RefreshClips(Media* m); + void undo(); + void redo(); +private: + Media* media; +}; + #endif // UNDO_H diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 3dd273c77..d56a36765 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -2347,6 +2347,10 @@ void TimelineWidget::paintEvent(QPaintEvent*) { p.drawImage(QRect(thumb_x, clip_rect.y()+thumb_y, thumb_clip_width, thumb_height), ms->video_preview, QRect(0, 0, thumb_clip_width*((double)ms->video_preview.width()/(double)thumb_width), ms->video_preview.height())); } } + if (clip->timeline_out - clip->timeline_in + clip->clip_in > clip->getMaximumLength()) { + draw_checkerboard = true; + checkerboard_rect.setLeft(panel_timeline->getTimelineScreenPointFromFrame(clip->getMaximumLength() + clip->timeline_in - clip->clip_in)); + } } else if (clip_rect.height() > TRACK_MIN_HEIGHT) { // draw waveform p.setPen(QColor(80, 80, 80));