# h.264 video codec of gstreamer

**URL:** <https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076>\
**Category:** Jetson Nano\
**Created:** [October 30, 2019, 12:22pm UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076 "2019-10-30T12:22:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [October 30, 2019, 12:22pm UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/1 "2019-10-30T12:22:30Z")

</div>

I try to use GST on nano to realize the hard decoding function of video stream. The pipeline command is as follows:  
(python dec.py --rtsp --uri “rtsp://192.168.1.100:554/user=admin&password=hg123456&channel=1&stream=0.sdp?”)  
but errors are reported all the time after execution. The errors are shown in the figure below.  
/////////////////**/////////////  
nvbuf\_utils: Could not get EGL display connection  
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline  
) in cvCaptureFromCAM\_GStreamer, file /home/lwin/Downloads/opencv/opencv-3.4.0/modules/videoio/src/cap\_gstreamer.cpp, line 890  
VIDEOIO(cvCreateCapture\_GStreamer (CV\_CAP\_GSTREAMER\_FILE, filename)): raised OpenCV exception:  
/home/lwin/Downloads/opencv/opencv-3.4.0/modules/videoio/src/cap\_gstreamer.cpp:890: error: (-2) GStreamer: unable to start pipeline  
in function cvCaptureFromCAM\_GStreamer  
////////////////**////////////  
I used this command to check the status of the camera.  
（gst-launch-1.0 rtspsrc location=“rtsp://192.168.1.100:554/user=admin&password=&channel=1&stream=0.sdp?” ! rtph264depay ! h264parse ! omxh264dec ! nveglglessink ）  
replied as follows:  
////////////////\*\*\*\*\*\*\*\*\*\*////////////  
nvbuf\_utils: Could not get EGL display connection  
Setting pipeline to PAUSED …

Using winsys: x11  
ERROR: Pipeline doesn’t want to pause.  
Setting pipeline to NULL …  
Freeing pipeline …  
////////////////\*\*\*\*\*\*\*\*\*\*////////////  
I tried some solutions, but all failed. Can you give me some suggestions?

 ![2.png](https://global.discourse-cdn.com/nvidia/original/2X/5/58c27ee2e2f02ff841c2142693484c9e8bd78346.png)  
 ![1.png](https://global.discourse-cdn.com/nvidia/original/2X/9/91e7f70a341a9d6b622a808195b32917dcb009d0.png)  
 ![3.png](https://global.discourse-cdn.com/nvidia/original/2X/9/935146ade15198b5e5976235e5c8ae3bf4933cd4.png)

---

<div class="post-metadata">

**Author:** ![simone.rinaldi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@simone.rinaldi](https://forums.developer.nvidia.com/u/simone.rinaldi)\
**Post date:** [October 30, 2019, 1:31pm UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/2 "2019-10-30T13:31:23Z")

</div>

To access to EGL display you need to have GUI enabled on Jetson an run the script from local terminal and not from SSH.  
If you have disabled GUI you can write directly to HDMI using nvdrmvideosink instead of nveglglessink

---

<div class="post-metadata">

**Author:** ![simone.rinaldi](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@simone.rinaldi](https://forums.developer.nvidia.com/u/simone.rinaldi)\
**Post date:** [October 30, 2019, 1:43pm UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/3 "2019-10-30T13:43:39Z")

</div>

> [@](#):
>
> I used this command to check the status of the camera.  
> （gst-launch-1.0 rtspsrc location=“rtsp://192.168.1.100:554/user=admin&password=&channel=1&stream=0.sdp?” ! rtph264depay ! h264parse ! omxh264dec ! nveglglessink ）

Anyway to check camera status, I suggest you to use:

```auto
gst-discoverer-1.0 rtsp://admin:Password@192.168.0.200:554/
Analyzing rtsp://admin:Password@192.168.0.200:554/
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Done discovering rtsp://admin:Password@192.168.0.200:554/

Topology:
  unknown: application/x-rtp
    video: H.264 (High Profile)

Properties:
  Duration: 99:99:99.999999999
  Seekable: no
  Live: yes
  Tags:
      video codec: H.264 (High Profile)

```

---

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [October 31, 2019, 1:19am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/4 "2019-10-31T01:19:58Z")

</div>

hi,simone.rinaldi,thank you for you reply.  
I run command on nano, The error is as follows:  
/////////////////**/////////////  
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline  
) in cvCaptureFromCAM\_GStreamer, file /home/lwin/Downloads/opencv/opencv-3.4.0/modules/videoio/src/cap\_gstreamer.cpp, line 890  
VIDEOIO(cvCreateCapture\_GStreamer (CV\_CAP\_GSTREAMER\_FILE, filename)): raised OpenCV exception:  
/home/lwin/Downloads/opencv/opencv-3.4.0/modules/videoio/src/cap\_gstreamer.cpp:890: error: (-2) GStreamer: unable to start pipeline  
in function cvCaptureFromCAM\_GStreamer  
////////////////**////////////  
It can’t be used either.  
I used the command to check the camera,print out as follow chart.Is the camera normal?

 ![4.jpg](https://global.discourse-cdn.com/nvidia/original/2X/f/f3210e37d858808d7dd676978f9ff1ebce5d5b64.jpeg)

 ![4.jpg](https://global.discourse-cdn.com/nvidia/original/2X/f/f3210e37d858808d7dd676978f9ff1ebce5d5b64.jpeg)

---

<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:** [October 31, 2019, 5:06am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/5 "2019-10-31T05:06:14Z")

</div>

Hi,  
Please check if the RTSP source works with nvoverlaysink:

```auto
gst-launch-1.0 rtspsrc location="rtsp://192.168.1.100:554/user=admin&password=&channel=1&stream=0.sdp?" ! rtph264depay ! h264parse ! omxh264dec ! nvoverlaysink

```

---

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [October 31, 2019, 5:33am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/6 "2019-10-31T05:33:02Z")

</div>

Hi,  
this is Reply to this order…

 ![5.jpg](https://global.discourse-cdn.com/nvidia/original/2X/3/32acc2daefe6466140af2a5962a8bd1c3ec8e331.jpeg)

 ![5.jpg](https://global.discourse-cdn.com/nvidia/original/2X/3/32acc2daefe6466140af2a5962a8bd1c3ec8e331.jpeg)

---

<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:** [October 31, 2019, 6:03am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/7 "2019-10-31T06:03:11Z")

</div>

Hi,  
It looks like URI is not correct. You may inspect it first.

---

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [October 31, 2019, 6:47am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/8 "2019-10-31T06:47:52Z")

</div>

Hi, DaneLLL,thank you!  
This is related to the camera. Because the manufacturer of the camera is different, the format of the user name and password is different when fetch stream. After the user name and password are modified according to the format specified by the manufacturer, the stream can be fetched normally.  
excuse me for my bad English. best wish to you!

---

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [November 5, 2019, 4:00am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/9 "2019-11-05T04:00:48Z")

</div>

Hi,  
Recently, I tried to encode video stream on nano. I want to encode a mp4 video use H265 or H265 format, and then decode it to MKV or MP4 format. I don’t know this idea is correct?

the gst command of encode is : gst-launch-1.0 filesrc location=xxx.mp4 ! ‘video/x-raw, format=(string)I420, width=(int)640, height=(int)480’ ! omxh264enc ! ‘video/x-h264,stream-format=byte-stream’ ! filesink location=test0.h264

the gst command of decode is : gst-launch-1.0 filesrc location=test0.h264. ! h264parse ! omxh264dec ! filesink location=test1.mp4

Is this ideal right? thank you!

---

<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 5, 2019, 6:09am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/10 "2019-11-05T06:09:24Z")

</div>

Hi,  
Your pipeline is not right. We have examples in user guide. Please check  
[https://developer.nvidia.com/embedded/dlc/l4t-accelerated-gstreamer-guide-32-2](https://developer.nvidia.com/embedded/dlc/l4t-accelerated-gstreamer-guide-32-2)

---

<div class="post-metadata">

**Author:** ![mdegans](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/mdegans/32/13104_2.png) [@mdegans](https://forums.developer.nvidia.com/u/mdegans)\
**Post date:** [November 5, 2019, 6:43pm UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/11 "2019-11-05T18:43:00Z")

</div>

> [@](#):
>
> Hi,  
> Recently, I tried to encode video stream on nano. I want to encode a mp4 video use H265 or H265 format, and then decode it to MKV or MP4 format. I don’t know this idea is correct?

Mkv, mp4, mov, and avi are just container formats that contain various video, audio, and metadata formats. h264, h265 are video codecs that go in the containers.

If you want to put a mp4 video containing h264 or h265 inside a .mkv container, you’re best off not re-encoding. Re-encoding always will lose quality, even if h265 is a better codec. Compression artifacts look like detail to compressors.

Instead you just need to demux (take apart) the .mp4 and remux (re-assemble) the streams inside the .mkv. You can do that with ffmpeg.

```auto
ffmpeg -i input.mp4 -codec copy output.mkv

```

If ffmpeg is not installed, you can install it with “sudo apt install ffmpeg”. If you absolutely do need to trasnscode (decode and re-encode), some examples to point you in the right direction can be found in the above post’s link.

---

<div class="post-metadata">

**Author:** ![kayccc](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kayccc/32/14043_2.png) [@kayccc](https://forums.developer.nvidia.com/u/kayccc)\
**Post date:** [February 5, 2020, 1:37am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/12 "2020-02-05T01:37:49Z")

</div>

#gstreamer  
#ffmpeg

Test, Test

---

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [November 6, 2019, 1:18am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/13 "2019-11-06T01:18:37Z")

</div>

Hello，thank you.  
My intention is to realize hard codec of video stream on nano. I want to use gst command to realize it, but not use ffmpeg.  
With the video test source of GST, I realized the codec to the display, but I didn’t know how to use the GST command in the code now.

---

<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 6, 2019, 2:29am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/14 "2019-11-06T02:29:07Z")

</div>

Hi,  
There are some samples of launching GST pipeline in C code. FYR.  
[https://devtalk.nvidia.com/default/topic/1058020/jetson-tx2/gstreamer-freeze-when-using-qtmux-and-nvidia-accelerated-h264-h265-encoding/post/5368623/#5368623](https://devtalk.nvidia.com/default/topic/1058020/jetson-tx2/gstreamer-freeze-when-using-qtmux-and-nvidia-accelerated-h264-h265-encoding/post/5368623/#5368623)  
[https://devtalk.nvidia.com/default/topic/1031734/jetson-tx2/appsrc-link-to-nvvidconv-error-with-reason-not-negotiated-4-/post/5250184/#5250184](https://devtalk.nvidia.com/default/topic/1031734/jetson-tx2/appsrc-link-to-nvvidconv-error-with-reason-not-negotiated-4-/post/5250184/#5250184)  
[https://devtalk.nvidia.com/default/topic/1011376/jetson-tx1/gstreamer-decode-live-video-stream-with-the-delay-difference-between-gst-launch-1-0-command-and-appsink-callback/post/5160929/#5160929](https://devtalk.nvidia.com/default/topic/1011376/jetson-tx1/gstreamer-decode-live-video-stream-with-the-delay-difference-between-gst-launch-1-0-command-and-appsink-callback/post/5160929/#5160929)

---

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [November 7, 2019, 8:13am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/15 "2019-11-07T08:13:36Z")

</div>

Hi,thank you

I refer to your link, use videotestsrc as the video source, modify some the commands of code, but the generated MP4 format file cannot play normally (VLC), and the code does not report any errors during execution, this is too strange,can you give me some suggestions,thank you again.

[#include   
#include   
#include   
#include \<gst/gst.h\>

using namespace std;

#define USE(x) ((void)(x))

static GstPipeline \*gst\_pipeline = nullptr;  
static string launch\_string;

GstClockTime usec = 1000000;  
static int w =1920;  
static int h = 1080;

int main(int argc, char\*\* argv) {  
USE(argc);  
USE(argv);

```
gst_init (&argc, &argv);

GMainLoop *main_loop;
main_loop = g_main_loop_new (NULL, FALSE);
ostringstream launch_stream;

launch_stream
//<< "videotestsrc ! "
//<< "video/x-raw(memory:NVMM),width="<< w <<",height="<< h <<",framerate=30/1,format=NV12 ! "
//<< "omxh264enc ! h264parse ! qtmux ! "
//<< "filesink location=test1.mp4 ";

<< "videotestsrc name=mysource num-buffers=120 ! "
<< "video/x-raw,width="<< w <<",height="<< h <<", ! "
<< "omxh264enc ! "
<< "video/x-h264,stream-format=byte-stream ! "
<< "filesink location=test1.mp4 ";

g_print("launch_stream");
launch_string = launch_stream.str();

g_print("Using launch string: %s\n", launch_string.c_str());

GError *error = nullptr;
gst_pipeline = (GstPipeline*) gst_parse_launch(launch_string.c_str(), &error);

if (gst_pipeline == nullptr) {
    g_print( "Failed to parse launch: %s\n", error->message);
    return -1;
}
if(error) g_error_free(error);

gst_element_set_state((GstElement*)gst_pipeline, GST_STATE_PLAYING); 

g_usleep(30*usec);

GstElement* src = gst_bin_get_by_name(GST_BIN(gst_pipeline), "mysource");
gst_element_send_event (src, gst_event_new_eos ());
// Wait for EOS message
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(gst_pipeline));
gst_bus_poll(bus, GST_MESSAGE_EOS, GST_CLOCK_TIME_NONE);

gst_element_set_state((GstElement*)gst_pipeline, GST_STATE_NULL);
gst_object_unref(GST_OBJECT(gst_pipeline));
g_main_loop_unref(main_loop);

g_print("going to exit \n");
return 0;

```

}]

 ![1.jpg](https://global.discourse-cdn.com/nvidia/original/2X/4/425c2c45d68fcc66cc014ca8633dcd872b4d00f0.jpeg)

---

<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 7, 2019, 8:52am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/16 "2019-11-07T08:52:45Z")

</div>

Hi,  
The pipeline generates h264 stream. You need qtmux to save playable mp4.

```auto
<< "videotestsrc name=mysource num-buffers=120 ! "
<< "video/x-raw,width="<< w <<",height="<< h <<", ! "
<< "omxh264enc ! "
<< "video/x-h264,stream-format=byte-stream ! "
<b><< "h264parse ! qtmux ! "</b>
<< "filesink location=test1.mp4 ";

```

---

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [November 7, 2019, 10:09am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/17 "2019-11-07T10:09:23Z")

</div>

thank you very much. The problem was solved just as you said.

Now I need to study how to input video data for encoding, and then send it out through the network. What’s your good sharing case?

---

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [November 11, 2019, 8:52am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/18 "2019-11-11T08:52:08Z")

</div>

hello，DaneLLL

Referring to this topic, I don’t know how to solve it later.  
[https://devtalk.nvidia.com/default/topic/1002805/jetson-tx1/mjstreamingerror-internal-data-flow-error-/?offset=9#5133272](https://devtalk.nvidia.com/default/topic/1002805/jetson-tx1/mjstreamingerror-internal-data-flow-error-/?offset=9#5133272)  
I did a small test with this open source code but it always printed the following report during the actual debugging.

I tried many ways, Let me know if you have any questions or suggestions.thank you!

---

<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 11, 2019, 8:58am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/19 "2019-11-11T08:58:37Z")

</div>

Hi,  
You may refer to tet-lauch.  
[https://devtalk.nvidia.com/default/topic/1018689/jetson-tx2/vlc-playing-gstreamer-flow/post/5187270/#5187270](https://devtalk.nvidia.com/default/topic/1018689/jetson-tx2/vlc-playing-gstreamer-flow/post/5187270/#5187270)  
It is a gstreamer sample of launching a RTSP server.

---

<div class="post-metadata">

**Author:** ![583873150](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@583873150](https://forums.developer.nvidia.com/u/583873150)\
**Post date:** [November 11, 2019, 9:08am UTC](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076/20 "2019-11-11T09:08:34Z")

</div>

Attachments and Codes  
[encode\_0.cpp](https://forums.developer.nvidia.com/uploads/short-url/tCNeV6d3SlcFzotz4GZIhrPg3aS.cpp) (8.03 KB)

 ![1111.jpg](https://global.discourse-cdn.com/nvidia/original/2X/f/f796cafb85e225649e96132267dfb7749dc0d642.jpeg)

[Next page](https://forums.developer.nvidia.com/t/h-264-video-codec-of-gstreamer/84076.md?page=2)
