H264 //使用Android手机的RTSP

时间:2018-06-15 12:15:57

标签: server rtsp gstreamer-1.0 nvidia-jetson

我想创建一个VR,所以我创建了一个RTSP服务器来链接到我的Zedmini。如果我使用h265编码器它是有效的,但坏的是RTSP仅在我使用Iphone7 VLC应用程序或计算机窗口8 VLC软件时才有效,我的Android手机huawei p7 Onvifer应用程序根本无法使用此RTSP地址。我需要将huawei p7用于我的项目,因为我要创建应用程序并链接到此RTSP服务器。

根据我的检查,有些Android设备不支持h265编码器,所以我决定使用h264并且我已经搜索了几个星期但是因为没有找到使用h264的解决方案而感到沮丧。

这是我从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; }

此代码正在开发流媒体视频,JX2相机,简单USB相机(低端),还有zedmini相机,但使用的是h265。我需要使用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 )");

0 个答案:

没有答案