Hi, I want to use opencv mat to stream to rtsp with gstreamer, and it successed on cpu.
but if i encode it by nvh264enc, it failed.
source code like this:
cv::VideoWriter out("appsrc ! videoconvert ! x264enc ! rtph264pay name=pay0 py=96 ! udpsink host=127.0.0.1 port=5000",cv::CAP_GSTREAMER,0,fps,size,true);
it works, and
cv::VideoWriter out("appsrc ! videoconvert ! nvh264enc gop-size=25 rc-mode=cbr bitrate=2000 ! h264parse ! rtph264pay name=py0 py=96 ! udpsink host=127.0.0.1 port=5000",cv::CAP_GSTREAMER,0,fps,size,true);
it failed.
it stream opencv mat to udpsink, stream to rtsp sink code is:
int main (int argc, char *argv[])
{
gst_init (&argc, &argv);
/* make a mainloop for the default context */
GMainLoop *loop;
loop = g_main_loop_new (NULL, FALSE);
/* create a server instance */
GstRTSPServer *server;
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 */
GstRTSPMountPoints *mounts;
mounts = gst_rtsp_server_get_mount_points (server);
guint64 udp_buffer_size = 512 * 1024;
int updsink_port_num = 5000;
char udpsrc_pipeline[512];
sprintf (udpsrc_pipeline,
"( udpsrc name=pay0 port=%d buffer-size=%lu caps=\"application/x-rtp, media=video, "
"clock-rate=90000, encoding-name=H264, payload=96 \" )",
updsink_port_num, udp_buffer_size);
/* 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 */
GstRTSPMediaFactory *factory;
factory = gst_rtsp_media_factory_new ();
gst_rtsp_media_factory_set_launch (factory, udpsrc_pipeline);
gst_rtsp_media_factory_set_shared (factory, TRUE);
/* attach the video test signal 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://127.0.0.1:8554/test\n");
g_main_loop_run (loop);
return 0;
}
Is there a way to push rtsp stream on gpu(nvh264enc)? or there is something wrong with gstreamer pipeline?
any any reply is appreciated.