private List<IGlFilter> createGlFilters(SourceMedia sourceMedia,
                                           TargetVideoTrack targetTrack,
                                           float overlayWidth,
                                           PointF position,
                                           float rotation)
        {
            List<IGlFilter> glFilters = null;
            if (targetTrack != null && targetTrack.overlay != null)
            {
                try
                {
                    Bitmap bitmap = BitmapFactory.DecodeStream(context.ContentResolver.OpenInputStream(targetTrack.overlay));
                    if (bitmap != null)
                    {
                        float overlayHeight;
                        VideoTrackFormat sourceVideoTrackFormat = (VideoTrackFormat)sourceMedia.tracks[targetTrack.sourceTrackIndex];
                        if (sourceVideoTrackFormat.rotation == 90 || sourceVideoTrackFormat.rotation == 270)
                        {
                            float overlayWidthPixels = overlayWidth * sourceVideoTrackFormat.height;
                            float overlayHeightPixels = overlayWidthPixels * bitmap.Height / bitmap.Width;
                            overlayHeight = overlayHeightPixels / sourceVideoTrackFormat.width;
                        }
                        else
                        {
                            float overlayWidthPixels = overlayWidth * sourceVideoTrackFormat.width;
                            float overlayHeightPixels = overlayWidthPixels * bitmap.Height / bitmap.Width;
                            overlayHeight = overlayHeightPixels / sourceVideoTrackFormat.height;
                        }

                        PointF size = new PointF(overlayWidth, overlayHeight);

                        IGlFilter filter = TransformationUtil.createGlFilter(context,
                                                                            targetTrack.overlay,
                                                                            size,
                                                                            position,
                                                                            rotation);
                        if (filter != null)
                        {
                            glFilters = new List<IGlFilter>();
                            glFilters.Add(filter);
                        }
                    }
                }
                catch (System.Exception err)
                {
                    System.Diagnostics.Debug.WriteLine($"Failed to extract audio track metadata: {err.Message}");
                }
            }

            return glFilters;
        }
        public static IGlFilter createGlFilter(Context context, Uri overlayUri, PointF size, PointF position, float rotation)
        {
            IGlFilter filter = null;

            Transform transform = new Transform(size, position, rotation);

            try
            {
                if (TextUtils.Equals(context.ContentResolver.GetType(overlayUri), "image/gif"))
                {
                    //IAnimationFrameProvider x;

                    /*
                     * ContentResolver contentResolver = context.ApplicationContext.ContentResolver;
                     * InputStream inputStream = contentResolver.OpenInputStream(overlayUri);
                     * BitmapPool bitmapPool = new LruBitmapPool(10);
                     * GifBitmapProvider gifBitmapProvider = new GifBitmapProvider(bitmapPool);
                     * GifDecoder gifDecoder = new StandardGifDecoder(gifBitmapProvider);
                     * gifDecoder.read(inputStream, (int)TranscoderUtils.getSize(context, overlayUri));
                     *
                     * AnimationFrameProvider animationFrameProvider = new AnimationFrameProvider() {
                     *  @Override
                     *  public int getFrameCount()
                     *  {
                     *      return gifDecoder.getFrameCount();
                     *  }
                     *
                     *  @Nullable
                     *  @Override
                     *      public Bitmap getNextFrame()
                     *  {
                     *      return gifDecoder.getNextFrame();
                     *  }
                     *
                     *  @Override
                     *      public long getNextFrameDurationNs()
                     *  {
                     *      return TimeUnit.MILLISECONDS.toNanos(gifDecoder.getNextDelay());
                     *  }
                     *
                     *  @Override
                     *      public void advance()
                     *  {
                     *      gifDecoder.advance();
                     *  }
                     * };
                     * filter = new FrameSequenceAnimationOverlayFilter(animationFrameProvider, transform);
                     */
                }
                else
                {
                    filter = new BitmapOverlayFilter(context.ApplicationContext, overlayUri, transform);
                }
            }
            catch (System.Exception err)
            {
                System.Diagnostics.Debug.WriteLine($"Failed to create a GlFilter: {err.Message}");
            }

            return(filter);
        }