Re: streaming .h264 video file using appsrc via rtsp

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: streaming .h264 video file using appsrc via rtsp

bhargavram
Hi,

I am streaming (.h264)video using  appsrc via rtsp (gstreamer -1.0). On
the client side with gstreamer-1.0 the video is streaming  with lag and
with gstreamer-0.10 the video is streaming fine.

Pipeline using gstreamer-1.0:
  "gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test !
rtpjitterbuffer ! rtph264depay ! h264parse ! decodebin  ! autovideosink"

Pipeline using gstreamer-0.10:
" gst-launch rtspsrc location=rtsp://127.0.0.1:8554/test  ! rtph264depay
! h264parse ! decodebin  ! autovideosink
"
we need to stream the video without lag using gstreamer-1.0

Can anyone help with some guide to stream the video without lag

Thanks & Regards,
M.Bhargav

**************** CAUTION - Disclaimer *****************This email may contain confidential and privileged material for the
sole use of the intended recipient(s). Any review, use, retention, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message. Also, email is susceptible to data corruption, interception, tampering, unauthorized amendment and viruses. We only send and receive emails on the basis that we are not liable for any such corruption, interception, tampering, amendment or viruses or any consequence thereof.
*********** End of Disclaimer ***********DataPatterns ITS Group**********

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: streaming .h264 video file using appsrc via rtsp

WisdomPill
Can you provide the source code of the server? I think I have the same issue.
Look over here
http://gstreamer-devel.966125.n4.nabble.com/RTSP-h264-sob-issue-td4686086.html

Regards, Anas



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: streaming .h264 video file using appsrc via rtsp

bhargavram
Hi,

Here is the source code of server

gstrtsp-server.c
<http://gstreamer-devel.966125.n4.nabble.com/file/t378196/gstrtsp-server.c>  



#include <gst/gst.h>

#include <gst/rtsp-server/rtsp-server.h>
#include <stdio.h>
#include <string.h>
typedef struct
{
        GstElement *element;
        GstElement *appsrc;
        guint sourceid ;
        GstClockTime timestamp;
} MyContext;
#define BUFF_SIZE (800*304*3)

FILE *file=NULL;
gpointer ptr=NULL;
/* called when we need to give data to appsrc */
//static void
//need_data (GstElement * appsrc, guint unused, MyContext * ctx)
static gboolean read_data(MyContext *ctx)
{
        GstBuffer *buffer;
        GstFlowReturn gstret;

        size_t ret = 0;
        GstMapInfo map;
        memset(ptr,0,BUFF_SIZE);
        // printf(" . ");
        buffer = gst_buffer_new_allocate (NULL, BUFF_SIZE, NULL);


        gst_buffer_map (buffer, &map, GST_MAP_WRITE);
        ret = fread(ptr, 1, BUFF_SIZE, file);
        map.size = BUFF_SIZE;
        memcpy(map.data,ptr,BUFF_SIZE);

        if(ret > 0)
        {
                gstret = gst_app_src_push_buffer(ctx->appsrc, buffer);
                if(gstret !=  GST_FLOW_OK){
                        printf("push buffer returned %d \n", gstret);
                        return FALSE;
                }

                // g_signal_emit_by_name (ctx->appsrc, "push-buffer", buffer, &gstret);
        }
        else
        {

                printf("\n failed to read from file\n");
                return FALSE;
        }

        gst_buffer_unmap (buffer, &map);
        return TRUE;
}



static void start_feed (GstElement * pipeline, guint size, MyContext *ctx)
{
        if (ctx->sourceid == 0) {
                printf ("\nstart feeding ");
                ctx->sourceid = g_idle_add ((GSourceFunc) read_data, ctx);
        }
}

static void stop_feed (GstElement * pipeline,MyContext *ctx)
{
        if (ctx->sourceid != 0) {
                printf ("\nstop feeding");
                g_source_remove (ctx->sourceid);
                ctx->sourceid = 0;
        }
}


/* called when a new media pipeline is constructed. We can query the
 * pipeline and configure our appsrc */
static void
media_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media,
    gpointer user_data)
{

        MyContext *ctx;

        ctx = g_new0 (MyContext, 1);
        /* get the element used for providing the streams of the media */
        ctx->element = gst_rtsp_media_get_element (media);

        /* get our appsrc, we named it 'mysrc' with the name property */
        ctx->appsrc = gst_bin_get_by_name_recurse_up (GST_BIN (ctx->element),
"mysrc");

        /* this instructs appsrc that we will be dealing with timed buffer */
// gst_util_set_object_arg (G_OBJECT (ctx->appsrc), "format", "time");
         g_object_set (G_OBJECT (ctx->appsrc),"format",GST_FORMAT_TIME,NULL);
        /* configure the caps of the video */
        g_object_set (G_OBJECT (ctx->appsrc), "caps",
                        gst_caps_new_simple ("video/x-h264",
                                "format", G_TYPE_STRING, "I420",
                                "width", G_TYPE_INT, 800,
                                "height", G_TYPE_INT, 608,
                                "framerate", GST_TYPE_FRACTION, 30, 1, NULL), NULL);

        /* make sure ther datais freed when the media is gone */
        g_object_set_data_full (G_OBJECT (media), "my-extra-data", ctx,
                        (GDestroyNotify) g_free);

        /* install the callback that will be called when a buffer is needed */
        g_signal_connect (ctx->appsrc, "need-data", G_CALLBACK(start_feed), ctx);
        g_signal_connect(ctx->appsrc, "enough-data", G_CALLBACK(stop_feed), ctx);
}

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

        if(argc != 2){
                printf("File name not specified\n");
                return 1;
        }

        ptr = g_malloc(BUFF_SIZE);
        g_assert(ptr);
        file = fopen(argv[1], "r");

        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 ();
        gst_rtsp_media_factory_set_launch (factory,
                        "(appsrc is-live=TRUE name=mysrc do-timestamp=TRUE ! h264parse  !
rtph264pay   name=pay0 pt=96 config-interval=1 )");

        /* notify when our media is ready, This is called whenever someone asks for
         * the media and a new pipeline with our appsrc is created */
        g_signal_connect (factory, "media-configure", (GCallback) media_configure,
                        NULL);

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

        /* don't need the ref to the mounts 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;
}



Regards,
Bhargav



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: streaming .h264 video file using appsrc via rtsp

noscgag
In reply to this post by bhargavram
Try adding the "latency=0" argument to the rtspsrc element, and "sync=false"
to the autovideosink element:

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test latency=0 !
rtpjitterbuffer ! rtph264depay ! h264parse ! decodebin  ! autovideosink
sync=false

I use a very similar pipeline and it is low latency:

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test latency=0 !
rtph264depay ! avdec_h264 ! autovideosink sync=false



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: streaming .h264 video file using appsrc via rtsp

bhargavram
Hi noscgag,


Thanks for your reply.

with this pipeline video is playing smoothly

     "gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test latency=0 !
      rtph264depay ! avdec_h264 ! autovideosink sync=false."

But unable to play this in vlc player(vlc as client  and gstreamer-1.0 as
server)

    "vlc rtsp://127.0.0.1:8554/test"




Regards,
Bhargav



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: streaming .h264 video file using appsrc via rtsp

bhargavram
Hi,

video file i am streaming is h264 encoded without container (using appsrc
and rtsp).


"Video: h264 (Constrained Baseline), yuv420p, 800x608, 25 fps, 25 tbr, 1200k
tbn, 50 tbc"


able to stream "using vlc/gstreamer  on both server and client" ,
but unable to stream with "gstreamer on server and vlc on client."

Can anyone help ?

Regards,
Bhargav



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

AW: streaming .h264 video file using appsrc via rtsp

Thornton, Keith
Hi,
I can stream H264 with rtsp to gstreamer and to VLC. What environment are you running on and what pipelines have you tried up till now

-----Ursprüngliche Nachricht-----
Von: gstreamer-devel [mailto:[hidden email]] Im Auftrag von bhargavram
Gesendet: Montag, 19. Februar 2018 08:51
An: [hidden email]
Betreff: Re: streaming .h264 video file using appsrc via rtsp

Hi,

video file i am streaming is h264 encoded without container (using appsrc and rtsp).


"Video: h264 (Constrained Baseline), yuv420p, 800x608, 25 fps, 25 tbr, 1200k tbn, 50 tbc"


able to stream "using vlc/gstreamer  on both server and client" , but unable to stream with "gstreamer on server and vlc on client."

Can anyone help ?

Regards,
Bhargav



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: AW: streaming .h264 video file using appsrc via rtsp

bhargavram
Hi,

here is the source code of server(linux)  
gstrtsp-server.c
<http://gstreamer-devel.966125.n4.nabble.com/file/t378196/gstrtsp-server.c>  


In client(linux/windows) using the below command
"vlc rtsp://127.0.0.1:8554/test"

Note:
I am able to stream h264 encoded video file with mp4 container and high
profile.
"Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x608, 151 kb/s, 25 fps,
25 tbr, 12800 tbn, 50 tbc (default )"


Regards,
Bhargav
 



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

AW: AW: streaming .h264 video file using appsrc via rtsp

Thornton, Keith
I see your h264 stream is already encoded before you push it to apsrc. Is it stream-format="byte-stream" and alignment="au"?

-----Ursprüngliche Nachricht-----
Von: gstreamer-devel [mailto:[hidden email]] Im Auftrag von bhargavram
Gesendet: Montag, 19. Februar 2018 09:57
An: [hidden email]
Betreff: Re: AW: streaming .h264 video file using appsrc via rtsp

Hi,

here is the source code of server(linux) gstrtsp-server.c <http://gstreamer-devel.966125.n4.nabble.com/file/t378196/gstrtsp-server.c>  


In client(linux/windows) using the below command "vlc rtsp://127.0.0.1:8554/test"

Note:
I am able to stream h264 encoded video file with mp4 container and high profile.
"Video: h264 (High) (avc1 / 0x31637661), yuv420p, 800x608, 151 kb/s, 25 fps,
25 tbr, 12800 tbn, 50 tbc (default )"


Regards,
Bhargav
 



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: AW: AW: streaming .h264 video file using appsrc via rtsp

bhargavram
Hi,

yes stream-format="byte-stream" and alignment="au".



Regards,
M.Bhargav
 





--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel