After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 759329 - convertframe: Support video crop when convert frame
convertframe: Support video crop when convert frame
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: 1.7.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-12-11 07:38 UTC by kevin
Modified: 2015-12-11 14:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Support video crop when convert frame (6.94 KB, patch)
2015-12-11 07:44 UTC, kevin
none Details | Review
Support video crop when convert frame (3.66 KB, patch)
2015-12-11 08:06 UTC, kevin
none Details | Review
Support video crop when convert frame (4.34 KB, patch)
2015-12-11 08:57 UTC, kevin
none Details | Review
Support video crop when convert frame (4.27 KB, patch)
2015-12-11 09:51 UTC, kevin
none Details | Review
Support video crop when convert frame. (4.73 KB, patch)
2015-12-11 14:00 UTC, kevin
committed Details | Review

Description kevin 2015-12-11 07:38:20 UTC
Get thumbnail will user convertframe to convert video frame to desired video format and size. But haven't process crop meta on the video buffer. Add support video crop.
Comment 1 kevin 2015-12-11 07:44:39 UTC
Created attachment 317185 [details] [review]
Support video crop when convert frame
Comment 2 kevin 2015-12-11 08:06:49 UTC
Created attachment 317186 [details] [review]
Support video crop when convert frame

Update the patch.
Comment 3 Sebastian Dröge (slomo) 2015-12-11 08:17:01 UTC
Review of attachment 317186 [details] [review]:

In theory videoscale and videoconvert could also do the cropping nowadays. GstVideoConverter has support for it. But making them do here if both converters don't have to convert everything might not be easy, needs to be checked

::: gst-libs/gst/video/convertframe.c
@@ +121,3 @@
   GST_DEBUG ("creating elements");
   if (!create_element ("appsrc", &src, &error) ||
+      !create_element ("videocrop", &vcrop, &error) ||

videocrop is in gst-plugins-good, so the usage of it here should be optional
Comment 4 kevin 2015-12-11 08:57:52 UTC
Created attachment 317188 [details] [review]
Support video crop when convert frame

Update patch based on review. Changed videocrop to optional element.
Comment 5 Sebastian Dröge (slomo) 2015-12-11 09:19:20 UTC
Review of attachment 317188 [details] [review]:

::: gst-libs/gst/video/convertframe.c
@@ +119,3 @@
 
+  if (!create_element ("videocrop", &vcrop, &error))
+    GST_DEBUG ("No videocrop element, can't process crop.");

Not a problem if no crop meta but see below

@@ +140,3 @@
+    gst_bin_add_many (GST_BIN (pipeline), src, vcrop, csp, vscale, sink, NULL);
+  else
+    gst_bin_add_many (GST_BIN (pipeline), src, csp, vscale, sink, NULL);

Maybe keep the old add_many() line and then only add a
if (vcrop) gst_bin_add (GST_BIN (pipeline), vcrop)

@@ +152,3 @@
+    GST_DEBUG ("crop meta [x,y,width,height]: %d %d %d %d", cmeta->x,
+        cmeta->y, cmeta->width, cmeta->height);
+  }

if (!vcrop && cmeta) this should probably print a g_warning()
Comment 6 kevin 2015-12-11 09:51:20 UTC
Created attachment 317191 [details] [review]
Support video crop when convert frame

Update based on review.
Comment 7 Sebastian Dröge (slomo) 2015-12-11 10:34:17 UTC
Review of attachment 317191 [details] [review]:

::: gst-libs/gst/video/convertframe.c
@@ +122,3 @@
+    if (cmeta)
+      g_warning ("buffer has crop meta, but no videocrop element. ");
+      g_warning ("can't process crop.");

Put this in a single g_warning() and prefix it with where this comes from, e.g.

g_warning("gst_video_convert_sample: Buffer has crop metadata but videocrop element is not found. Cropping will be disabled")

@@ +142,3 @@
   GST_DEBUG ("adding elements");
   gst_bin_add_many (GST_BIN (pipeline), src, csp, vscale, sink, NULL);
+  if (vcrop) gst_bin_add (GST_BIN (pipeline), vcrop);

You should also run gst-indent on your .c files before you submit patches :) A line break is missing here

@@ +163,3 @@
+      goto link_failed;
+
+    GST_DEBUG ("linking vcrop->csp");

It might be necessary to have another videoconvert before videocrop too
Comment 8 kevin 2015-12-11 14:00:09 UTC
Created attachment 317208 [details] [review]
Support video crop when convert frame.

Update patch based on review.
Comment 9 Nicolas Dufresne (ndufresne) 2015-12-11 14:10:55 UTC
As the videoconvert library now support convert/scale/crop in one pass, can't we just update videoconvert to support all this, and then we don't need multiple elements/pass here ?
Comment 10 Sebastian Dröge (slomo) 2015-12-11 14:16:01 UTC
commit a476145797d3ea2d3d1467a48b18fc5000a3b8a1
Author: Song Bing <b06498@freescale.com>
Date:   Fri Dec 11 21:42:00 2015 +0800

    video/convertframe: Add crop meta support via videocrop
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759329
Comment 11 Sebastian Dröge (slomo) 2015-12-11 14:16:49 UTC
(In reply to Nicolas Dufresne (stormer) from comment #9)
> As the videoconvert library now support convert/scale/crop in one pass,
> can't we just update videoconvert to support all this, and then we don't
> need multiple elements/pass here ?

See comment #3 :) I was going to open a new bug for that, the videoconvert refactoring is going to be some more work though.
Comment 12 Sebastian Dröge (slomo) 2015-12-11 14:19:06 UTC
The other question I just noticed is... why does it use the CROP meta at all if downstream is an appsink? appsink is not going to report that it can CROP, so putting a CROP meta on the buffers would be wrong anyway.
Comment 13 kevin 2015-12-11 14:42:10 UTC
The video buffer which has CROP meta is get from video sink. The video sink can handle CROP meta. Thumbnail function will get the last-buffer from the video sink and convert it to user's desired format. So we should consider the CROP meta to get right thumbnail.
Comment 14 Sebastian Dröge (slomo) 2015-12-11 14:52:09 UTC
Makes sense