# gstreamer does not start encoding

**URL:** <https://forums.developer.nvidia.com/t/gstreamer-does-not-start-encoding/107928>\
**Category:** Jetson TX2\
**Created:** [November 24, 2019, 8:15am UTC](https://forums.developer.nvidia.com/t/gstreamer-does-not-start-encoding/107928 "2019-11-24T08:15:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![igal.kroyter](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@igal.kroyter](https://forums.developer.nvidia.com/u/igal.kroyter)\
**Post date:** [November 24, 2019, 8:15am UTC](https://forums.developer.nvidia.com/t/gstreamer-does-not-start-encoding/107928/1 "2019-11-24T08:15:39Z")

</div>

Hi,

starting a gstreamer pipeline which encodes h.264 to a file prints out the following lines to terminal:

```auto
Framerate set to : 60 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
===== MSENC blits (mode: 1) into tiled surfaces =====

```

Once in a while I do not get the last line, that Is I’m getting only:

```auto
Framerate set to : 60 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4

```

as a result I get no file.  
what might be the reason, or how can I debug it?  
Thanks.

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [November 25, 2019, 2:42am UTC](https://forums.developer.nvidia.com/t/gstreamer-does-not-start-encoding/107928/2 "2019-11-25T02:42:33Z")

</div>

Hi,  
You may add prints in gst\_omx\_video\_enc\_handle\_output\_frame() in gst-omx source, to check if encoder outputs h264 stream.

---

<div class="post-metadata">

**Author:** ![igal.kroyter](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@igal.kroyter](https://forums.developer.nvidia.com/u/igal.kroyter)\
**Post date:** [November 25, 2019, 1:08pm UTC](https://forums.developer.nvidia.com/t/gstreamer-does-not-start-encoding/107928/3 "2019-11-25T13:08:21Z")

</div>

DaneLLL, hi,

I have a callback function that is invoked upon frame recceival down the pipeline and I see that I don’t get any frames.  
This phenomenon happens rarely, thus this makes it impossible to catch if I print anything to terminal while encoding multiple channels.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [December 6, 2019, 5:00am UTC](https://forums.developer.nvidia.com/t/gstreamer-does-not-start-encoding/107928/4 "2019-12-06T05:00:48Z")

</div>

Hi,  
Please try the following patch for gst-omx:

```auto
diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c
index 5d614f3..6af360a 100644
--- a/omx/gstomxvideoenc.c
+++ b/omx/gstomxvideoenc.c
@@ -28,6 +28,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "gstomxvideoenc.h"
 #include "gstnvivameta_api.h"
@@ -1096,6 +1097,8 @@ gst_omx_video_enc_handle_output_frame (GstOMXVideoEnc * self, GstOMXPort * port,
   return flow_ret;
 }
 
+static gint firstAcquire = 0;
+static gint acquireRetry = 0;
 static void
 gst_omx_video_enc_loop (GstOMXVideoEnc * self)
 {
@@ -1109,14 +1112,25 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self)
 
   klass = GST_OMX_VIDEO_ENC_GET_CLASS (self);
 
+acquire:
   acq_return = gst_omx_port_acquire_buffer (port, &buf);
   if (acq_return == GST_OMX_ACQUIRE_BUFFER_ERROR) {
+ g_print("GST_OMX_ACQUIRE_BUFFER_ERROR \n");
     goto component_error;
   } else if (acq_return == GST_OMX_ACQUIRE_BUFFER_FLUSHING) {
- goto flushing;
+ g_print("GST_OMX_ACQUIRE_BUFFER_FLUSHING \n");
+ if (firstAcquire == 0 && acquireRetry < 5) {
+ acquireRetry++;
+ g_print("Acquire buffer retry - %d \n", acquireRetry);
+ usleep(8000);
+ goto acquire;
+ } else
+ goto flushing;
   } else if (acq_return == GST_OMX_ACQUIRE_BUFFER_EOS) {
+ g_print("GST_OMX_ACQUIRE_BUFFER_EOS \n");
     goto eos;
   }
+ firstAcquire = 1;
 
   if (!gst_pad_has_current_caps (GST_VIDEO_ENCODER_SRC_PAD (self))
       || acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE) {

```

We hit a race condition that encoding does not start on r24 releases. Although you use r28.2, it is still worth a try. Please apply it and see if it helps.

---

<div class="post-metadata">

**Author:** ![igal.kroyter](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@igal.kroyter](https://forums.developer.nvidia.com/u/igal.kroyter)\
**Post date:** [December 8, 2019, 10:45am UTC](https://forums.developer.nvidia.com/t/gstreamer-does-not-start-encoding/107928/5 "2019-12-08T10:45:52Z")

</div>

DaneLLL, hi,

thanks for the patch, I have added the patch and we’ll start the test to verify that there are no more failures.

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 18, 2021, 6:34pm UTC](https://forums.developer.nvidia.com/t/gstreamer-does-not-start-encoding/107928/6 "2021-10-18T18:34:45Z")

</div>

Closed on October 18, 2021, 6:34pm UTC


