diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index 2f17d9063..bedcd7214 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -45,26 +45,28 @@ void PreviewGenerator::parse_media() { ms->file_index = i; append = true; } - if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { - if (fmt_ctx->streams[i]->avg_frame_rate.den == 0) { // source is LIKELY a still image - ms->infinite_length = true; - contains_still_image = true; - ms->video_frame_rate = 0; - } else { - ms->infinite_length = false; + if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO + && fmt_ctx->streams[i]->codecpar->width > 0 + && fmt_ctx->streams[i]->codecpar->height > 0) { + if (fmt_ctx->streams[i]->avg_frame_rate.den == 0) { // source is LIKELY a still image + ms->infinite_length = true; + contains_still_image = true; + ms->video_frame_rate = 0; + } else { + ms->infinite_length = false; ms->video_frame_rate = av_q2d(fmt_ctx->streams[i]->avg_frame_rate); } - ms->video_width = fmt_ctx->streams[i]->codecpar->width; - ms->video_height = fmt_ctx->streams[i]->codecpar->height; - if (append) media->video_tracks.append(ms); + ms->video_width = fmt_ctx->streams[i]->codecpar->width; + ms->video_height = fmt_ctx->streams[i]->codecpar->height; + if (append) media->video_tracks.append(ms); } else if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { ms->audio_channels = fmt_ctx->streams[i]->codecpar->channels; ms->audio_layout = fmt_ctx->streams[i]->codecpar->channel_layout; ms->audio_frequency = fmt_ctx->streams[i]->codecpar->sample_rate; if (append) media->audio_tracks.append(ms); - } else { - delete ms; - } + } else if (append) { + delete ms; + } } } media->length = fmt_ctx->duration; diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index bb86a7b92..1a856aec9 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -22,6 +22,7 @@ EffectControls::EffectControls(QWidget *parent) : QDockWidget(parent), + multiple(false), zoom(1), ui(new Ui::EffectControls) { @@ -37,6 +38,8 @@ EffectControls::EffectControls(QWidget *parent) : ui->keyframeView->header = ui->headers; + ui->label_2->setVisible(false); + connect(ui->keyframeScroller->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->scrollArea->verticalScrollBar(), SLOT(setValue(int))); connect(ui->keyframeScroller->horizontalScrollBar(), SIGNAL(valueChanged(int)), ui->keyframeHeaderScroller->horizontalScrollBar(), SLOT(setValue(int))); } @@ -174,29 +177,33 @@ void EffectControls::deselect_all_effects(QWidget* sender) { } void EffectControls::load_effects() { - // load in new clips - for (int i=0;iget_clip(selected_clips.at(i)); - QVBoxLayout* layout; - if (c->track < 0) { - ui->vcontainer->setVisible(true); - layout = static_cast(ui->video_effect_area->layout()); - } else { - ui->acontainer->setVisible(true); - layout = static_cast(ui->audio_effect_area->layout()); + ui->label_2->setVisible(multiple); + + if (!multiple) { + // load in new clips + for (int i=0;iget_clip(selected_clips.at(i)); + QVBoxLayout* layout; + if (c->track < 0) { + ui->vcontainer->setVisible(true); + layout = static_cast(ui->video_effect_area->layout()); + } else { + ui->acontainer->setVisible(true); + layout = static_cast(ui->audio_effect_area->layout()); + } + for (int j=0;jeffects.size();j++) { + Effect* e = c->effects.at(j); + CollapsibleWidget* container = e->container; + layout->addWidget(container); + connect(container, SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*))); + } } - for (int j=0;jeffects.size();j++) { - Effect* e = c->effects.at(j); - CollapsibleWidget* container = e->container; - layout->addWidget(container); - connect(container, SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*))); + if (selected_clips.size() > 0) { + ui->keyframeView->setMinimumHeight(ui->effects_area->height()); + ui->keyframeView->setEnabled(true); + ui->headers->setVisible(true); + ui->keyframeView->update(); } - } - if (selected_clips.size() > 0) { - ui->keyframeView->setMinimumHeight(ui->effects_area->height()); - ui->keyframeView->setEnabled(true); - ui->headers->setVisible(true); - ui->keyframeView->update(); } } diff --git a/panels/effectcontrols.h b/panels/effectcontrols.h index 8f2e214e7..4e92f87af 100644 --- a/panels/effectcontrols.h +++ b/panels/effectcontrols.h @@ -39,6 +39,7 @@ public: void set_zoom(bool in); bool keyframe_focus(); void delete_selected_keyframes(); + bool multiple; QVector selected_clips; diff --git a/panels/effectcontrols.ui b/panels/effectcontrols.ui index ef35b45db..bc31d6bb0 100644 --- a/panels/effectcontrols.ui +++ b/panels/effectcontrols.ui @@ -399,6 +399,16 @@ + + + + (Multiple clips selected) + + + Qt::AlignCenter + + + diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 1671095fe..f718fecd2 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -810,48 +810,45 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { // find out how many clips are selected // limits to one video clip and one audio clip and only if they're linked // one of these days it might be nice to have multiple clips in the effects panel - bool got_vclip = false; - bool got_aclip = false; + panel_effect_controls->multiple = false; int vclip = -1; int aclip = -1; for (int i=0;iclip_count();i++) { Clip* clip = sequence->get_clip(i); - if (clip != NULL && panel_timeline->is_clip_selected(clip, true)) { - if (clip->track < 0) { - if (got_vclip) { - vclip = -1; - } else { - vclip = i; - got_vclip = true; - } - } else { - if (got_aclip) { - aclip = -1; - } else { - aclip = i; - got_aclip = true; - } - } + if (clip != NULL && panel_timeline->is_clip_selected(clip, true)) { + if (clip->track < 0 && vclip == -1) { + vclip = i; + } else if (clip->track >= 0 && aclip == -1) { + aclip = i; + } else { + vclip = -2; + aclip = -2; + panel_effect_controls->multiple = true; + break; + } } } // check if aclip is linked to vclip QVector selected_clips; - if (vclip != -1) selected_clips.append(vclip); - if (aclip != -1) selected_clips.append(aclip); - if (vclip != -1 && aclip != -1) { - bool found = false; - Clip* vclip_ref = sequence->get_clip(vclip); - for (int i=0;ilinked.size();i++) { - if (vclip_ref->linked.at(i) == aclip) { - found = true; - break; - } - } - if (!found) { - // only display multiple clips if they're linked - selected_clips.clear(); - } - } + if (!panel_effect_controls->multiple) { + if (vclip >= 0) selected_clips.append(vclip); + if (aclip >= 0) selected_clips.append(aclip); + if (vclip >= 0 && aclip >= 0) { + bool found = false; + Clip* vclip_ref = sequence->get_clip(vclip); + for (int i=0;ilinked.size();i++) { + if (vclip_ref->linked.at(i) == aclip) { + found = true; + break; + } + } + if (!found) { + // only display multiple clips if they're linked + selected_clips.clear(); + panel_effect_controls->multiple = true; + } + } + } panel_effect_controls->set_clips(selected_clips); } } diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 4b8e9453b..4612c371a 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -34,8 +34,8 @@ ViewerWidget::ViewerWidget(QWidget *parent) : format.setDepthBufferSize(24); setFormat(format); - // error handler - retries after 250ms if we couldn't get the entire image - retry_timer.setInterval(250); + // error handler - retries after 500ms if we couldn't get the entire image + retry_timer.setInterval(500); connect(&retry_timer, SIGNAL(timeout()), this, SLOT(retry())); }