From 2b943597657c46ac11135ead4dd30db5fd565d50 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Fri, 13 May 2022 10:23:54 +1000 Subject: [PATCH 1/1] ges/videourisource: handle non-1/1 PAR source videos The automatic scaling done by framepositioner does not account for the par of the video source. Part-of: --- .../ges/ges-video-uri-source.c | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-editing-services/ges/ges-video-uri-source.c b/subprojects/gst-editing-services/ges/ges-video-uri-source.c index 3eef67b..fe6d514 100644 --- a/subprojects/gst-editing-services/ges/ges-video-uri-source.c +++ b/subprojects/gst-editing-services/ges/ges-video-uri-source.c @@ -108,6 +108,7 @@ ges_video_uri_source_get_natural_size (GESVideoSource * source, gint * width, const GstTagList *tags = NULL; gchar *rotation_info = NULL; gint videoflip_method, rotate_angle; + guint par_n, par_d; GstDiscovererVideoInfo *info = _get_video_stream_info (GES_VIDEO_URI_SOURCE (source)); @@ -116,6 +117,21 @@ ges_video_uri_source_get_natural_size (GESVideoSource * source, gint * width, *width = gst_discoverer_video_info_get_width (info); *height = gst_discoverer_video_info_get_height (info); + + /* account for source video PAR being not 1/1 */ + par_n = gst_discoverer_video_info_get_par_num (info); + par_d = gst_discoverer_video_info_get_par_denom (info); + + if (par_n > 0 && par_d > 0) { + if (*height % par_n == 0) { + *height = gst_util_uint64_scale_int (*height, par_d, par_n); + } else if (*width % par_d == 0) { + *height = gst_util_uint64_scale_int (*width, par_n, par_d); + } else { + *width = gst_util_uint64_scale_int (*height, par_d, par_n); + } + } + if (!ges_timeline_element_lookup_child (GES_TIMELINE_ELEMENT (source), "GstVideoFlip::video-direction", NULL, NULL)) goto done; @@ -151,11 +167,14 @@ done: return TRUE; rotate: - GST_INFO_OBJECT (source, "Stream is rotated, taking that into account"); - *width = - gst_discoverer_video_info_get_height (GST_DISCOVERER_VIDEO_INFO (info)); - *height = - gst_discoverer_video_info_get_width (GST_DISCOVERER_VIDEO_INFO (info)); + { + gint tmp; + + GST_INFO_OBJECT (source, "Stream is rotated, taking that into account"); + tmp = *width; + *width = *height; + *height = tmp; + } goto done; } -- 2.7.4