JX2, ZedMINI GStreamer, RTSP server using Android phone

hi all,

i have tried all the methods but fail to figure out.
need your helps on this:

i would like to create a VR.
Thus, i create RTSP server to link to my Zedmini, it is work if i use h265 encoder,
but the bad thing is the RTSP only work if i use Iphone7 VLC app or computer window 8 VLC software,
my Android phone huawei p7 Onvifer app cannot generic this RTSP address at all. And i need to use huawei p7 for my project as i am going to create the app and link to this RTSP server.

Based on my checking, Some Android device not support h265 encoder, so i decided to use h264 and i have been googling a lot for few weeks but frustrated without finding a solution for using h264.

Really need your assistance if you hv any idea>>>>

This is the code which i amend from test-readme.c >>>>>>

#include <gst/gst.h>

#include <gst/rtsp-server/rtsp-server.h>

int
main (int argc, char *argv[])
{
  GMainLoop *loop;
  GstRTSPServer *server;
  GstRTSPMountPoints *mounts;
  GstRTSPMediaFactory *factory;

  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

  /* create a server instance */
  server = gst_rtsp_server_new ();

  /* get the mount points for this server, every server has a default object
   * that be used to map uri mount points to media factories */
  mounts = gst_rtsp_server_get_mount_points (server);

  /* make a media factory for a test stream. The default media factory can use
   * gst-launch syntax to create pipelines. 
   * any launch line works as long as it contains elements named pay%d. Each
   * element with pay%d names will be a stream */
  factory = gst_rtsp_media_factory_new ();
  
//working case for streaming video
//gst_rtsp_media_factory_set_launch (factory,"( videotestsrc is-live=1 ! x264enc ! rtph264pay name=pay0 pt=96 )");

//working case for external camera
//gst_rtsp_media_factory_set_launch (factory,"( v4l2src is-live=1 device=/dev/video1 ! video/x-raw, width=(int)720, height=(int)480 framerate=30/1 format=I420 ! timeoverlay ! omxh265enc ! rtph265pay name=pay0 pt=96 )");

//working case for JX2 camera
//gst_rtsp_media_factory_set_launch (factory,"( nvcamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=1920, height=1080, framerate=30/1, format=I420 ! nvvidconv flip-method=4 !video/x-raw, width=(int)720, height=(int)480 framerate=30/1 format=I420 ! timeoverlay ! omxh265enc ! rtph265pay name=pay0 pt=96 )");

//Fail or not working case for Zed mini camera testing FOR H264
gst_rtsp_media_factory_set_launch (factory,"(v4l2src is-live=1 device=/dev/video1 ! video/x-raw, width=2560, height=720, framerate=30/1, format=I420 ! nvvidconv !video/x-raw, width=(int)720, height=(int)480, framerate=30/1, format=NV12 ! omxh264enc bitrate=10000000 ! rtph264pay name=pay0 pt=96 )");

//working case for Zed mini camera FOR H265
//gst_rtsp_media_factory_set_launch (factory,"(v4l2src is-live=1 device=/dev/video1 ! video/x-raw, width=2560, height=720, framerate=30/1, format=I420 ! nvvidconv !video/x-raw, width=(int)720, height=(int)480 framerate=30/1 format=I420 ! timeoverlay ! omxh265enc ! rtph265pay name=pay0 pt=96 )");

gst_rtsp_media_factory_set_shared (factory, TRUE);
  /* attach the test factory to the /test url */
  gst_rtsp_mount_points_add_factory (mounts, "/test", factory);

  /* don't need the ref to the mapper anymore */
  g_object_unref (mounts);

  /* attach the server to the default maincontext */
  gst_rtsp_server_attach (server, NULL);

  /* start serving */
  g_print ("stream ready at rtsp://172.16.124.75:8554/test\n");
  g_main_loop_run (loop);

  return 0;
}

This code is working on streaming video, JX2 camera, simple USB camera (low end), also zedmini camera but using h265. i need the code running using h264, there must be some element missed out here or wrong, pls help me if you hv any idea for it, thanks again:

gst_rtsp_media_factory_set_launch (factory,"(v4l2src is-live=1 device=/dev/video1 ! video/x-raw, width=2560, height=720, framerate=30/1, format=I420 ! nvvidconv !video/x-raw, width=(int)720, height=(int)480, framerate=30/1, format=NV12 ! omxh264enc bitrate=10000000 ! rtph264pay name=pay0 pt=96 )");

Try to change the caps after nvvidconv to:

... nvvidconv !video/x-raw<b>(memory:NVMM)</b>, width=(int)720, height=(int)480, framerate=30/1, format=I420 ! omxh264enc ...

i have changed my code as adding (memory:NVMM) behind nvvidconv !video/x-raw,
but it still fail and pop out below:

nvidia@tegra-ubuntu:~/Downloads/gst-rtsp-server-1.8.1/examples$ ./test-readmestream ready at rtsp://172.16.124.75:8554/test
Framerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameter^C
nvidia@tegra-ubuntu:~/Downloads/gst-rtsp-server-1.8.1/examples$

Are you using standard v1.8.3 gstreamer-1.0 ?
The option is-live is not correct for v4l2src (I know it as an option from videotestsrc). You may remove it.

On my TX2 (R28.2-DP) with ZED (not mini, but seems to have same formats), the pipeline looks working :

gst-launch-1.0 -e v4l2src device=/dev/video1 ! 'video/x-raw, format=YUY2' ! nvvidconv ! 'video/x-raw(memory:NVMM), format=I420, width=720, height=480, framerate=30/1' ! omxh264enc bitrate=10000000 ! rtph264pay name=pay0 pt=96  ! fakesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Framerate set to : 30 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
===== MSENC blits (mode: 1) into tiled surfaces =====

Does it work for you ?

Hi, I am using standard v1.8.1 gstreamer-1.0, i have removed the option “is-live” but some error pop out:

Framerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameterFramerate set to : 30 at NvxVideoEncoderSetParameter^Z
[1]+  Stopped                 ./test-readme
nvidia@tegra-ubuntu:~/Downloads/gst-rtsp-server-1.8.1/examples$

You may try this pipeline:

v4l2src device=/dev/video1 ! video/x-raw, format=YUY2 ! nvvidconv ! video/x-raw(memory:NVMM), format=I420 ! omxh264enc ! video/x-h264, <b>profile=baseline</b>, width=720, height=480, framerate=30/1 ! rtph264pay pt=96 name=pay0

hi Honey_Patouceul, thank you for your help again.
I changed the pipeline as same as yours:

gst_rtsp_media_factory_set_launch (factory,"(v4l2src device=/dev/video1 ! video/x-raw, format=YUY2 ! nvvidconv ! video/x-raw(memory:NVMM), format=I420 ! omxh264enc ! video/x-h264, profile=baseline, width=720, height=480, framerate=30/1 ! rtph264pay pt=96 name=pay0)");

The client terminal becomes:

Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://127.16.124.75:8554/test
Progress: (open) Retrieving server options
0:00:20.149968637  4139       0x64c400 WARN                 rtspsrc gstrtspsrc.c:5508:gst_rtspsrc_try_send:<rtspsrc0> error: Could not receive message. (Timeout while waiting for server response)
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not read from resource.
Additional debug info:
gstrtspsrc.c(5508): gst_rtspsrc_try_send (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Could not receive message. (Timeout while waiting for server response)
0:00:20.151852666  4139       0x64c400 WARN                 rtspsrc gstrtspsrc.c:6898:gst_rtspsrc_open:<rtspsrc0> can't get sdp
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
0:00:20.152184174  4139       0x64c400 WARN                 rtspsrc gstrtspsrc.c:5075:gst_rtspsrc_loop:<rtspsrc0> we are not connected
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
nvidia@tegra-ubuntu:~$ ^C

Nothing came out, any more idea? Really appreciate your assistance!!

Seems the client fails to open the stream. The IP looks a bit strange to me… Is this the static IP of your Jetson ? And did you set it in rtsp server code ?

I’m running R28.2-DP, and just tested with test-launch (in gst-rtsp-server/examples that defaults to localhost server 127.0.0.1):

./test-launch "v4l2src device=/dev/video1 ! video/x-raw, format=YUY2 ! nvvidconv ! video/x-raw(memory:NVMM), format=I420 ! omxh264enc ! video/x-h264, profile=baseline, width=720, height=480, framerate=30/1 ! rtph264pay pt=96 name=pay0"

and client in a second terminal on Jetson:

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test ! decodebin ! videoconvert ! ximagesink

If this does work, you may have to set the rtsp-server address in your server code and try running the client from another machine (your android phone). Not sure you need parenthesis inside the pipeline string. You may also try to remove these.

If this doesn’t work, you may consider backup your work and reflash with last JetPack.

–Removed. Posted in wrong topic.