Nvcompositor does not position according to the X,Y parameter values

Hi,

I’m trying to position an compositor pipeline. Unfortunately, the values given for the X,Y parameters does not change in the output and position to the center of the screen.

The pipeline as follows:

gst-launch-1.0 -e videotestsrc pattern=black ! video/x-raw,width=320,height=240 ! nvvidconv ! queue ! tee name=t5 ! queue ! comp1.sink_0 filesrc location= /home/usr/Downloads/white.png ! image/png,width=960,height=270,framerate=0/1,pixel-aspect-ratio=1/1 ! pngdec ! videoconvert ! imagefreeze ! video/x-raw,framerate=30/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),width=960,height=270,format=NV12,pixel-aspect-ratio=1/1' ! queue !  comp1.sink_1 filesrc location=/home/usr/Downloads/red.png ! image/png,width=960,height=270,framerate=0/1,pixel-aspect-ratio=1/1 ! pngdec ! videoconvert ! imagefreeze ! video/x-raw,framerate=30/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),width=960,height=270,format=NV12,pixel-aspect-ratio=1/1' ! queue ! comp1.sink_3 nvcompositor name=comp1 sink_0::width=1920 sink_0::height=100 sink_0::ypos=2   sink_1::xpos=960 sink_1::width=960 sink_1::height=270 sink_2::xpos=9 sink_2::ypos=295 sink_2::width=960 sink_2::height=540 sink_4::ypos=295  ! nvvidconv ! nvoverlaysink overlay=2

Thanks in advance.

Hi,
Please apply this patch and rebuild nvcompositor plugin:
Jetson/L4T/r32.6.x patches - eLinux.org

[gstreamer] patch for running v4l2src + nvcompositor

With the patch, we can configure background resolution. If background resolution is fixed, the X Y parameters should take effect. Please give it a try.

how to apply this patch?

You may avoid odd coordinates or sizes. This works:

gst-launch-1.0 -v \
videotestsrc pattern=black ! video/x-raw,width=320,height=240 ! nvvidconv  ! 'video/x-raw(memory:NVMM),width=720,height=100,format=NV12' ! nvvidconv ! 'video/x-raw(memory:NVMM),width=1920,height=100,format=RGBA,pixel-aspect-ratio=1/1' ! tee name=t5 ! queue ! comp1.sink_0 \
filesrc location=white_960x270.png ! image/png,width=960,height=270,framerate=0/1,pixel-aspect-ratio=1/1 ! pngdec ! videoconvert ! imagefreeze ! video/x-raw,framerate=30/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),width=960,height=270,format=RGBA,pixel-aspect-ratio=1/1' ! queue !  comp1.sink_1 \
filesrc location=red_960x540.png ! image/png,width=960,height=540,framerate=0/1,pixel-aspect-ratio=1/1 ! pngdec ! videoconvert ! imagefreeze ! video/x-raw,framerate=30/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),width=960,height=540,format=RGBA,pixel-aspect-ratio=1/1' ! queue ! comp1.sink_2 \
nvcompositor name=comp1 \
  sink_0::xpos=0    sink_0::ypos=0   sink_0::width=1920 sink_0::height=100  sink_0::zorder=1 \
  sink_1::xpos=960  sink_1::ypos=0   sink_1::width=960  sink_1::height=270  sink_1::zorder=2 \
  sink_2::xpos=0    sink_2::ypos=296 sink_2::width=960  sink_2::height=540  sink_2::zorder=3 \
 ! nvvidconv ! autovideosink
1 Like

Hi,

When i try to apply the patch, i get errors in the terminal as mentioned below.

libgstnvcompositor.c:1:6: error: expected β€˜=’, β€˜,’, β€˜;’, β€˜asm’ or β€˜__attribute__’ before β€˜--’ token
 diff --git a/gst-nvcompositor/gstnvcompositor.c b/gst-nvcompositor/gstnvcompositor.c
      ^~
libgstnvcompositor.c:5:1: error: stray β€˜@’ in program
 @@ -708,7 +708,9 @@ gst_nvcompositor_pad_init (GstNvCompositorPad * nvcompo_pad)
 ^
libgstnvcompositor.c:5:2: error: stray β€˜@’ in program
 @@ -708,7 +708,9 @@ gst_nvcompositor_pad_init (GstNvCompositorPad * nvcompo_pad)
  ^
libgstnvcompositor.c:5:18: error: stray β€˜@’ in program
 @@ -708,7 +708,9 @@ gst_nvcompositor_pad_init (GstNvCompositorPad * nvcompo_pad)
                  ^
libgstnvcompositor.c:5:19: error: stray β€˜@’ in program
 @@ -708,7 +708,9 @@ gst_nvcompositor_pad_init (GstNvCompositorPad * nvcompo_pad)
                   ^
libgstnvcompositor.c:16:1: error: stray β€˜@’ in program
 @@ -784,6 +786,12 @@ gst_nvcompositor_set_property (GObject * object,
 ^
libgstnvcompositor.c:16:2: error: stray β€˜@’ in program
 @@ -784,6 +786,12 @@ gst_nvcompositor_set_property (GObject * object,
  ^
libgstnvcompositor.c:16:4: error: expected identifier or β€˜(’ before β€˜-’ token
 @@ -784,6 +786,12 @@ gst_nvcompositor_set_property (GObject * object,
    ^
libgstnvcompositor.c:16:19: error: stray β€˜@’ in program
 @@ -784,6 +786,12 @@ gst_nvcompositor_set_property (GObject * object,
                   ^
libgstnvcompositor.c:16:20: error: stray β€˜@’ in program
 @@ -784,6 +786,12 @@ gst_nvcompositor_set_property (GObject * object,
                    ^
libgstnvcompositor.c:19:8: error: expected identifier or β€˜(’ before β€˜break’
        break;
        ^~~~~
libgstnvcompositor.c:20:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +    case PROP_BACKGROUND_WIDTH:
 ^
libgstnvcompositor.c:22:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +      break;
 ^
libgstnvcompositor.c:23:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +    case PROP_BACKGROUND_HEIGHT:
 ^
libgstnvcompositor.c:25:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +      break;
 ^
libgstnvcompositor.c:26:6: error: expected identifier or β€˜(’ before β€˜default’
      default:
      ^~~~~~~
libgstnvcompositor.c:28:8: error: expected identifier or β€˜(’ before β€˜break’
        break;
        ^~~~~
libgstnvcompositor.c:29:1: error: stray β€˜@’ in program
 @@ -808,6 +816,12 @@ gst_nvcompositor_get_property (GObject * object,
 ^
libgstnvcompositor.c:29:2: error: stray β€˜@’ in program
 @@ -808,6 +816,12 @@ gst_nvcompositor_get_property (GObject * object,
  ^
libgstnvcompositor.c:29:4: error: expected identifier or β€˜(’ before β€˜-’ token
 @@ -808,6 +816,12 @@ gst_nvcompositor_get_property (GObject * object,
    ^
libgstnvcompositor.c:29:19: error: stray β€˜@’ in program
 @@ -808,6 +816,12 @@ gst_nvcompositor_get_property (GObject * object,
                   ^
libgstnvcompositor.c:29:20: error: stray β€˜@’ in program
 @@ -808,6 +816,12 @@ gst_nvcompositor_get_property (GObject * object,
                    ^
libgstnvcompositor.c:32:8: error: expected identifier or β€˜(’ before β€˜break’
        break;
        ^~~~~
libgstnvcompositor.c:33:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +    case PROP_BACKGROUND_WIDTH:
 ^
libgstnvcompositor.c:35:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +      break;
 ^
libgstnvcompositor.c:36:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +    case PROP_BACKGROUND_HEIGHT:
 ^
libgstnvcompositor.c:38:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +      break;
 ^
libgstnvcompositor.c:39:6: error: expected identifier or β€˜(’ before β€˜default’
      default:
      ^~~~~~~
libgstnvcompositor.c:41:8: error: expected identifier or β€˜(’ before β€˜break’
        break;
        ^~~~~
libgstnvcompositor.c:42:1: error: stray β€˜@’ in program
 @@ -837,6 +851,7 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
 ^
libgstnvcompositor.c:42:2: error: stray β€˜@’ in program
 @@ -837,6 +851,7 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
  ^
libgstnvcompositor.c:42:4: error: expected identifier or β€˜(’ before β€˜-’ token
 @@ -837,6 +851,7 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
    ^
libgstnvcompositor.c:42:18: error: stray β€˜@’ in program
 @@ -837,6 +851,7 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
                  ^
libgstnvcompositor.c:42:19: error: stray β€˜@’ in program
 @@ -837,6 +851,7 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
                   ^
libgstnvcompositor.c:44:4: error: unknown type name β€˜gint’; did you mean β€˜int’?
    gint suitable_width = -1, suitable_height = -1;
    ^~~~
    int
libgstnvcompositor.c:45:4: error: unknown type name β€˜GstVideoAggregator’
    GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (agg);
    ^~~~~~~~~~~~~~~~~~
libgstnvcompositor.c:45:31: warning: implicit declaration of function β€˜GST_VIDEO_AGGREGATOR’ [-Wimplicit-function-declaration]
    GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (agg);
                               ^~~~~~~~~~~~~~~~~~~~
libgstnvcompositor.c:45:53: error: β€˜agg’ undeclared here (not in a function); did you mean β€˜vagg’?
    GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (agg);
                                                     ^~~
                                                     vagg
libgstnvcompositor.c:46:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +  GstNvCompositor *nvcomp = GST_NVCOMPOSITOR (vagg);
 ^
libgstnvcompositor.c:48:4: warning: data definition has no type or storage class
    ret = gst_caps_make_writable (caps);
    ^~~
libgstnvcompositor.c:48:4: warning: type defaults to β€˜int’ in declaration of β€˜ret’ [-Wimplicit-int]
libgstnvcompositor.c:48:10: warning: implicit declaration of function β€˜gst_caps_make_writable’ [-Wimplicit-function-declaration]
    ret = gst_caps_make_writable (caps);
          ^~~~~~~~~~~~~~~~~~~~~~
libgstnvcompositor.c:48:34: error: β€˜caps’ undeclared here (not in a function)
    ret = gst_caps_make_writable (caps);
                                  ^~~~
libgstnvcompositor.c:50:1: error: stray β€˜@’ in program
 @@ -897,6 +912,10 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
 ^
libgstnvcompositor.c:50:2: error: stray β€˜@’ in program
 @@ -897,6 +912,10 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
  ^
libgstnvcompositor.c:50:4: error: expected identifier or β€˜(’ before β€˜-’ token
 @@ -897,6 +912,10 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
    ^
libgstnvcompositor.c:50:19: error: stray β€˜@’ in program
 @@ -897,6 +912,10 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
                   ^
libgstnvcompositor.c:50:20: error: stray β€˜@’ in program
 @@ -897,6 +912,10 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
                    ^
libgstnvcompositor.c:52:6: warning: data definition has no type or storage class
      suitable_fps_d = 1;
      ^~~~~~~~~~~~~~
libgstnvcompositor.c:52:6: warning: type defaults to β€˜int’ in declaration of β€˜suitable_fps_d’ [-Wimplicit-int]
libgstnvcompositor.c:53:4: error: expected identifier or β€˜(’ before β€˜}’ token
    }
    ^
libgstnvcompositor.c:54:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +  if (nvcomp->bg_width > 0 && nvcomp->bg_height > 0) {
 ^
libgstnvcompositor.c:59:54: error: expected β€˜)’ before string constant
    gst_structure_fixate_field_nearest_fraction (str, "framerate", suitable_fps_n,
                                                      ^~~~~~~~~~~
libgstnvcompositor.c:61:1: error: stray β€˜@’ in program
 @@ -1421,6 +1440,15 @@ gst_nvcompositor_class_init (GstNvCompositorClass * klass)
 ^
libgstnvcompositor.c:61:2: error: stray β€˜@’ in program
 @@ -1421,6 +1440,15 @@ gst_nvcompositor_class_init (GstNvCompositorClass * klass)
  ^
libgstnvcompositor.c:61:4: error: expected identifier or β€˜(’ before β€˜-’ token
 @@ -1421,6 +1440,15 @@ gst_nvcompositor_class_init (GstNvCompositorClass * klass)
    ^
libgstnvcompositor.c:61:21: error: stray β€˜@’ in program
 @@ -1421,6 +1440,15 @@ gst_nvcompositor_class_init (GstNvCompositorClass * klass)
                     ^
libgstnvcompositor.c:61:22: error: stray β€˜@’ in program
 @@ -1421,6 +1440,15 @@ gst_nvcompositor_class_init (GstNvCompositorClass * klass)
                      ^
libgstnvcompositor.c:65:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +  g_object_class_install_property (gobject_class, PROP_BACKGROUND_WIDTH,
 ^
libgstnvcompositor.c:69:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +  g_object_class_install_property (gobject_class, PROP_BACKGROUND_HEIGHT,
 ^
libgstnvcompositor.c:73:1: error: expected identifier or β€˜(’ before β€˜+’ token
 +
 ^
libgstnvcompositor.c:75:0: error: unterminated #if
  #if 0

Hi,
Please refer to this command:
How to Run β€œpatch” Command in Linux?

Or you may remove + and merge the patch manually.