From 938aaaef249095d5c982027b04837ed2421040bd Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 1 Jul 2015 17:28:52 +0200 Subject: [PATCH] ges: Do not add a final gap at the end of track while rendering It is not correct to force a black frame at the end of the rendered video and it also leads to rendering issue with vpX encoders. https://bugzilla.gnome.org/show_bug.cgi?id=751510 --- ges/ges-internal.h | 4 ++++ ges/ges-pipeline.c | 30 ++++++++++++++++++++++-------- ges/ges-track.c | 16 +++++++++++++--- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/ges/ges-internal.h b/ges/ges-internal.h index 28f0fde532..d855df8fcf 100644 --- a/ges/ges-internal.h +++ b/ges/ges-internal.h @@ -111,6 +111,10 @@ G_GNUC_INTERNAL void track_resort_and_fill_gaps (GESTrack *track); +G_GNUC_INTERNAL +void +track_disable_last_gap (GESTrack *track, gboolean disabled); + G_GNUC_INTERNAL void ges_asset_cache_init (void); diff --git a/ges/ges-pipeline.c b/ges/ges-pipeline.c index 9feefa0dac..79849e6ee2 100644 --- a/ges/ges-pipeline.c +++ b/ges/ges-pipeline.c @@ -124,8 +124,8 @@ _overlay_set_render_rectangle (GstVideoOverlay * overlay, gint x, { GESPipeline *pipeline = GES_PIPELINE (overlay); - gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (pipeline-> - priv->playsink), x, y, width, height); + gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (pipeline->priv-> + playsink), x, y, width, height); } static void @@ -133,8 +133,8 @@ _overlay_set_window_handle (GstVideoOverlay * overlay, guintptr handle) { GESPipeline *pipeline = GES_PIPELINE (overlay); - gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (pipeline->priv-> - playsink), handle); + gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (pipeline-> + priv->playsink), handle); } static void @@ -225,6 +225,9 @@ static void _timeline_track_added_cb (GESTimeline * timeline, GESTrack * track, GESPipeline * pipeline) { + track_disable_last_gap (track, + ! !(pipeline->priv->mode & (GES_PIPELINE_MODE_RENDER | + GES_PIPELINE_MODE_SMART_RENDER))); _link_track (pipeline, track); } @@ -807,8 +810,9 @@ _link_track (GESPipeline * self, GESTrack * track) } /* Connect to encodebin */ - if (self->priv-> - mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER)) { + if (self-> + priv->mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER)) + { GstPad *tmppad; GST_DEBUG_OBJECT (self, "Connecting to encodebin"); @@ -1071,9 +1075,11 @@ ges_pipeline_get_mode (GESPipeline * pipeline) gboolean ges_pipeline_set_mode (GESPipeline * pipeline, GESPipelineFlags mode) { + + GList *tmp; g_return_val_if_fail (GES_IS_PIPELINE (pipeline), FALSE); - GST_DEBUG_OBJECT (pipeline, "current mode : %d, mode : %d", + GST_ERROR_OBJECT (pipeline, "current mode : %d, mode : %d", pipeline->priv->mode, mode); /* fast-path, nothing to change */ @@ -1087,6 +1093,15 @@ ges_pipeline_set_mode (GESPipeline * pipeline, GESPipelineFlags mode) /* Switch pipeline to NULL since we're changing the configuration */ gst_element_set_state (GST_ELEMENT_CAST (pipeline), GST_STATE_NULL); + + if (pipeline->priv->timeline) { + gboolean disabled = + ! !(mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER)); + + for (tmp = pipeline->priv->timeline->tracks; tmp; tmp = tmp->next) + track_disable_last_gap (GES_TRACK (tmp->data), disabled); + } + /* remove no-longer needed components */ if (pipeline->priv->mode & GES_PIPELINE_MODE_PREVIEW && !(mode & GES_PIPELINE_MODE_PREVIEW)) { @@ -1128,7 +1143,6 @@ ges_pipeline_set_mode (GESPipeline * pipeline, GESPipelineFlags mode) (mode & GES_PIPELINE_MODE_PREVIEW)) { /* Add playsink */ GST_DEBUG ("Adding playsink"); - if (!gst_bin_add (GST_BIN_CAST (pipeline), pipeline->priv->playsink)) { GST_ERROR_OBJECT (pipeline, "Couldn't add playsink"); return FALSE; diff --git a/ges/ges-track.c b/ges/ges-track.c index 4e18fb8a4f..95e76a33d8 100644 --- a/ges/ges-track.c +++ b/ges/ges-track.c @@ -62,6 +62,7 @@ struct _GESTrackPrivate GSequence *trackelements_by_start; GHashTable *trackelements_iter; GList *gaps; + gboolean last_gap_disabled; guint64 duration; @@ -234,14 +235,23 @@ update_gaps (GESTrack * track) } } - GST_DEBUG_OBJECT (track, "Adding a one second gap at the end"); - gap = gap_new (track, timeline_duration, 1); - priv->gaps = g_list_prepend (priv->gaps, gap); + if (!track->priv->last_gap_disabled) { + GST_DEBUG_OBJECT (track, "Adding a one second gap at the end"); + gap = gap_new (track, timeline_duration, 1); + priv->gaps = g_list_prepend (priv->gaps, gap); + } /* 4- Remove old gaps */ g_list_free_full (gaps, (GDestroyNotify) free_gap); } +void +track_disable_last_gap (GESTrack * track, gboolean disabled) +{ + track->priv->last_gap_disabled = disabled; + update_gaps (track); +} + void track_resort_and_fill_gaps (GESTrack * track) {