I am trying to rotate a video by degrees that are not divisible by 90.
Like this [0] pipeline . However I am not able to find any solutions that don't involve losing pixels and/or support alpha. So far the best thing I have found is videoflip, and it works well for 90/180/270 Does anyone know a solution, and if not would an element be welcome for this? Or maybe I can add a patch to rotate (but for my use case I would want the sink to always have alpha) and the height/width would be re-calculated every time the angle changed. thanks --- [0] gst-launch-1.0 videotestsrc ! rotate angle=5 ! compositor sink_0::xpos=200 sink_0::ypos=200 ! video/x-raw,width=1280,height=720 ! autovideosink _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Le 17 déc. 2017 1:59 AM, "Sean DuBois" <[hidden email]> a écrit : I am trying to rotate a video by degrees that are not divisible by 90. Improving rotate seems a good way. The only other solution I know is gltransformation, note that it depends on graphene, which is not always included in distribution yet (gtk4 will depend on it).
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
> On Sun, Dec 17, 2017 at 07:59:17AM -0500, Nicolas Dufresne wrote:
> > Le 17 déc. 2017 1:59 AM, "Sean DuBois" <[hidden email]> a écrit : > > > > I am trying to rotate a video by degrees that are not divisible by 90. > > Like this [0] pipeline . However I am not able to find any solutions > > that don't involve losing pixels and/or support alpha. > > > > So far the best thing I have found is videoflip, and it works well for > > 90/180/270 > > > > Does anyone know a solution, and if not would an element be welcome for > > this? Or maybe I can add a patch to rotate (but for my use case I would > > want the sink to always have alpha) and the height/width would be > > re-calculated every time the angle changed. > > > > > Improving rotate seems a good way. The only other solution I know is > gltransformation, note that it depends on graphene, which is not always > included in distribution yet (gtk4 will depend on it). > > > > > > thanks > > > > --- > > [0] gst-launch-1.0 videotestsrc ! rotate angle=5 ! compositor > > sink_0::xpos=200 sink_0::ypos=200 ! video/x-raw,width=1280,height=720 ! > > autovideosink Awesome, thanks Nicolas! After I get AV1 in a better state, I want to tackle this. This is something I would really like in an application I currently have. I will send Thiago Santos an email, he is the author and maybe he has some ideas/plans already. gltransformation isn't a great fit for me (I am pretty sure), I am doing things on hosts without a real GPU (Running in a Hypervisor) _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by Sean DuBois
On Sun, 17 Dec 2017 00:48:32 -0600
Sean DuBois <[hidden email]> wrote: > I am trying to rotate a video by degrees that are not divisible by 90. > Like this [0] pipeline . However I am not able to find any solutions > that don't involve losing pixels and/or support alpha. > > So far the best thing I have found is videoflip, and it works well for > 90/180/270 > > Does anyone know a solution, and if not would an element be welcome for > this? Or maybe I can add a patch to rotate (but for my use case I would > want the sink to always have alpha) and the height/width would be > re-calculated every time the angle changed. > About the alpha, you have to set caps before the rotation to make sure you are using a format which does have an alpha channel, like in: gst-launch-1.0 videotestsrc ! video/x-raw,format=ARGB ! ... ! videoconvert ! autovideosink About the off-edge-pixels: 1. If you do not want to lose pixels, composite to a bigger transparent frame and rotate that: gst-launch-1.0 videotestsrc ! video/x-raw,format=ARGB ! compositor background=transparent sink_0::xpos=160 sink_0::ypos=120 ! video/x-raw,width=640,height=480 ! rotate angle=5 ! compositor sink_0::xpos=200 sink_0::ypos=200 ! video/x-raw,width=1280,height=720 ! videoconvert ! autovideosink 2. If shrinking the image is fine, then use an affine transform to rotate scale and translate at the same time, if you cannot use gltransformation you can try the "perspective" element which does everything on the CPU, you'll have to pass the calculated matrix from code. The matrix can be calculated with the formula from here: https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#getrotationmatrix2d Adding one last row set to [0,0,1] because "perspective" expects a 3x3 matrix. Maybe "perspective" wasn't the best name for the element as it performs a generic matrix transform. Ciao, Antonio -- Antonio Ospite https://ao2.it https://twitter.com/ao2it A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing? _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
On Mon, Dec 18, 2017 at 01:00:54PM +0100, Antonio Ospite wrote:
> On Sun, 17 Dec 2017 00:48:32 -0600 > Sean DuBois <[hidden email]> wrote: > > > I am trying to rotate a video by degrees that are not divisible by 90. > > Like this [0] pipeline . However I am not able to find any solutions > > that don't involve losing pixels and/or support alpha. > > > > So far the best thing I have found is videoflip, and it works well for > > 90/180/270 > > > > Does anyone know a solution, and if not would an element be welcome for > > this? Or maybe I can add a patch to rotate (but for my use case I would > > want the sink to always have alpha) and the height/width would be > > re-calculated every time the angle changed. > > > > About the alpha, you have to set caps before the rotation to make sure you > are using a format which does have an alpha channel, like in: > > gst-launch-1.0 videotestsrc ! video/x-raw,format=ARGB ! ... ! videoconvert ! autovideosink > > About the off-edge-pixels: > > 1. If you do not want to lose pixels, composite to a bigger > transparent frame and rotate that: > > gst-launch-1.0 videotestsrc ! video/x-raw,format=ARGB ! compositor background=transparent sink_0::xpos=160 sink_0::ypos=120 ! video/x-raw,width=640,height=480 ! rotate angle=5 ! compositor sink_0::xpos=200 sink_0::ypos=200 ! video/x-raw,width=1280,height=720 ! videoconvert ! autovideosink > > 2. If shrinking the image is fine, then use an affine transform to > rotate scale and translate at the same time, if you cannot use > gltransformation you can try the "perspective" element which does > everything on the CPU, you'll have to pass the calculated matrix from > code. > > The matrix can be calculated with the formula from here: > https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#getrotationmatrix2d > > Adding one last row set to [0,0,1] because "perspective" expects > a 3x3 matrix. > > Maybe "perspective" wasn't the best name for the element as it > performs a generic matrix transform. > > > Ciao, > Antonio > > -- > Antonio Ospite > https://ao2.it > https://twitter.com/ao2it > > A: Because it messes up the order in which people normally read text. > See http://en.wikipedia.org/wiki/Posting_style > Q: Why is top-posting such a bad thing? That is a really clever hack for off-edge-pixels, thanks Antonio! That will work perfectly for me short term, but it would be nice to have a solution out of the box (and will try my best to get it in-tree) _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
On Mon, 18 Dec 2017 13:29:06 -0600
Sean DuBois <[hidden email]> wrote: [...] > That is a really clever hack for off-edge-pixels, thanks Antonio! > You mean using a bigger frame? Or using "perspective"? > That will work perfectly for me short term, but it would be nice to have > a solution out of the box (and will try my best to get it in-tree) The "perspective" element is in-tree already, here is an example of how to use it for rotations around the center: https://git.ao2.it/experiments/gstreamer.git/blob/HEAD:/python/gst-test-perspective.py#l31 I used cv2.getRotationMatrix2D for convenience but creating the matrix is not that hard. However I'd be interested in a more intuitive solution. :) Please, keep me posted. Ciao, Antonio -- Antonio Ospite https://ao2.it https://twitter.com/ao2it A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing? _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |