How to do streaming of mp4 file using rtsp on gstreamer (simulating the live stream)

danil4u danil4u at gmail.com
Fri Oct 18 12:46:55 CEST 2013



We are trying to stream the mp4 file using the rtsp. We could able to do the
streaming on the client side without any problem but whenever we connect the
client and play, it starts to play from the beginning (something like video
on demand). But our intention is simulating the live streaming with the
stored mp4 files itself. Can anybody through some light on it.

Here is the example code that we are trying on server side...

#include <gst/gst.h>

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

int
main (int argc, char *argv[])
{
  GMainLoop *loop;
    //GError *error;
GstElement *pipeline;
GstBus *bus;
  GstMessage *msg;
  GstRTSPServer *server;
  GstRTSPMediaMapping *mounts;
  GstRTSPMediaFactory *factory;
  gchar *str ,*str1;

  gst_init (&argc, &argv);

  if (argc < 2) {
    g_message ("usage: %s <filename.mp4>", argv[0]);
    return -1;
  }


 loop = g_main_loop_new (NULL, FALSE);

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

  /* 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);

 str1 = g_strdup_printf ("( "
      "filesrc location=%s  ! qtdemux name=d " 
      "d. ! queue ! ffdec_h264 ! x264enc ! rtph264pay pt=96 name=pay0 "
      ")", argv[1]); 

  /* 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 ();
  gst_rtsp_media_factory_set_launch (factory, str1);

  g_free (str1);

  /* attach the test factory to the /test url */
  gst_rtsp_media_mapping_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_main_loop_run (loop);

  return 0;
}

The client command that we used is

gst-launch rtspsrc location="rtsp://10.0.0.28:8554/test" ! rtph264depay !
ffdec_h264 ! autovideosink

thanks




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-do-streaming-of-mp4-file-using-rtsp-on-gstreamer-simulating-the-live-stream-tp4662693.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list