video play fast with gst new buffer allocation

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

video play fast with gst new buffer allocation

anil0407
Hi,

In a _chain function(custom plugin), when i move to the existing gst buffer
to new gst buffer, i observed that the video is playing very fast.
what changes required to make it play normal speed.
Here the snippet code:
        buf = gst_buffer_make_writable (buf);
       
        buf_size = gst_buffer_get_size (buf);
        n_buf = gst_buffer_new_allocate (NULL, buf_size, NULL);
        gst_buffer_map (n_buf, &n_map, GST_MAP_WRITE);

        if (gst_buffer_map (buf, &map, GST_MAP_WRITE)) {
                ptr = (guint16 *) map.data;
                memcpy((guint16 *)n_map.data, (guint16 *)ptr, buf_size);
                gst_buffer_unmap (buf, &map);
                gst_buffer_unmap (n_buf, &n_map);
                return gst_pad_push (filter->srcpad, n_buf);
        }

Thanks,
Anil



--
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: video play fast with gst new buffer allocation

Thornton, Keith
Hi,
your new buffer is missing PTS, DURATION and OFFSET stuff. You should set these with the values from the original buffer
Gruesse

-----Ursprüngliche Nachricht-----
Von: gstreamer-devel <[hidden email]> Im Auftrag von anil0407
Gesendet: Montag, 1. März 2021 06:40
An: [hidden email]
Betreff: video play fast with gst new buffer allocation

Hi,

In a _chain function(custom plugin), when i move to the existing gst buffer to new gst buffer, i observed that the video is playing very fast.
what changes required to make it play normal speed.
Here the snippet code:
        buf = gst_buffer_make_writable (buf);
       
        buf_size = gst_buffer_get_size (buf);
        n_buf = gst_buffer_new_allocate (NULL, buf_size, NULL);
        gst_buffer_map (n_buf, &n_map, GST_MAP_WRITE);

        if (gst_buffer_map (buf, &map, GST_MAP_WRITE)) {
                ptr = (guint16 *) map.data;
                memcpy((guint16 *)n_map.data, (guint16 *)ptr, buf_size);
                gst_buffer_unmap (buf, &map);
                gst_buffer_unmap (n_buf, &n_map);
                return gst_pad_push (filter->srcpad, n_buf);
        }

Thanks,
Anil



--
Sent from: https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgstreamer-devel.966125.n4.nabble.com%2F&amp;data=04%7C01%7C%7C0c5803fad2f8452e1bac08d8dcb410c7%7C28042244bb514cd680347776fa3703e8%7C1%7C1%7C637502013219035498%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=pAYmTjj3TBQ0z1c6W%2BleCuncT5%2Fo5s%2FHBAUrugcSvLI%3D&amp;reserved=0
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fgstreamer-devel&amp;data=04%7C01%7C%7C0c5803fad2f8452e1bac08d8dcb410c7%7C28042244bb514cd680347776fa3703e8%7C1%7C1%7C637502013219035498%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=Sza7VQyQ7BL85T7MKMd2u%2Br8q1uTE9WjPUsufu7JQ9M%3D&amp;reserved=0
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: AW: video play fast with gst new buffer allocation

anil0407
Hi,

After adding PTS, DURATION and OFFSET stuff...small video is playing good
but longer video getting hang.


Here the snippet code:
        buf = gst_buffer_make_writable (buf);
       
        buf_size = gst_buffer_get_size (buf);
        n_buf = gst_buffer_new_allocate (NULL, buf_size, NULL);
        gst_buffer_map (n_buf, &n_map, GST_MAP_WRITE);

        if (gst_buffer_map (buf, &map, GST_MAP_WRITE)) {
                ptr = (guint16 *) map.data;

                GST_BUFFER_DURATION (n_buf) = GST_BUFFER_DURATION (buf);
                GST_BUFFER_PTS (n_buf) = GST_BUFFER_PTS (buf);
                GST_BUFFER_OFFSET(n_buf) = GST_BUFFER_OFFSET(buf);

                memcpy((guint16 *)n_map.data, (guint16 *)ptr, buf_size);
                gst_buffer_unmap (buf, &map);
                gst_buffer_unmap (n_buf, &n_map);
                return gst_pad_push (filter->srcpad, n_buf);
        }

Thanks,
Anil



--
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: video play fast with gst new buffer allocation

Thornton, Keith
Hi
Just as an example you might like to look at the following


        GstSample* pSample = gst_app_sink_pull_sample(appsink);
        if (!pSample) {
            MULTIMEDIA_ERROR << " sample == nullptr";
            return GST_FLOW_ERROR;
        }

        GstBuffer* pBuffer = gst_sample_get_buffer(pSample);
        if (!pBuffer) {
            MULTIMEDIA_ERROR << "failed to get buffer from sample";
            gst_sample_unref(pSample);
            return GST_FLOW_ERROR;
        }

        GstBuffer* pNewBuffer = gst_buffer_copy_deep(pBuffer);
        if (!pNewBuffer) {
            MULTIMEDIA_ERROR << "failed to create new buffer for streaming";
            return GST_FLOW_ERROR;
        }

        GstCaps* pNewCaps = gst_sample_get_caps(pSample);
        GstSegment* pSegment = gst_sample_get_segment(pSample);
        GstSample* pNewSample = gst_sample_new(pNewBuffer, pNewCaps, pSegment, nullptr);
        gst_sample_unref(pSample);

        if (! pNewSample) {
            MULTIMEDIA_ERROR << "failed to get buffer from sample";
            gst_buffer_unref(pNewBuffer);
            return GST_FLOW_ERROR;
        }


        GstFlowReturn ret = gst_app_src_push_sample(appSrc, pNewSample);
        if (ret == GST_FLOW_OK) {
            MULTIMEDIA_TRACE << "PTS=" << GST_BUFFER_PTS(pNewBuffer) << ", DTS=" << GST_BUFFER_DTS(pNewBuffer) << ", DURATION=" << GST_BUFFER_DURATION(pNewBuffer);
        }
        else {
            MULTIMEDIA_ERROR << "failed to push the buffer downstream, error code = " << ret;
            gst_buffer_unref(pNewBuffer);
            gst_sample_unref(pNewSample);
            return GST_FLOW_OK;
        }
        //        g_signal_emit_by_name(appsrc, "push-buffer", buffer, &ret);

        gst_buffer_unref(pNewBuffer);
        gst_sample_unref(pNewSample);
        return ret;
    }

-----Ursprüngliche Nachricht-----
Von: gstreamer-devel <[hidden email]> Im Auftrag von anil0407
Gesendet: Donnerstag, 4. März 2021 12:46
An: [hidden email]
Betreff: Re: AW: video play fast with gst new buffer allocation

Hi,

After adding PTS, DURATION and OFFSET stuff...small video is playing good but longer video getting hang.


Here the snippet code:
        buf = gst_buffer_make_writable (buf);
       
        buf_size = gst_buffer_get_size (buf);
        n_buf = gst_buffer_new_allocate (NULL, buf_size, NULL);
        gst_buffer_map (n_buf, &n_map, GST_MAP_WRITE);

        if (gst_buffer_map (buf, &map, GST_MAP_WRITE)) {
                ptr = (guint16 *) map.data;

                GST_BUFFER_DURATION (n_buf) = GST_BUFFER_DURATION (buf);
                GST_BUFFER_PTS (n_buf) = GST_BUFFER_PTS (buf);
                GST_BUFFER_OFFSET(n_buf) = GST_BUFFER_OFFSET(buf);

                memcpy((guint16 *)n_map.data, (guint16 *)ptr, buf_size);
                gst_buffer_unmap (buf, &map);
                gst_buffer_unmap (n_buf, &n_map);
                return gst_pad_push (filter->srcpad, n_buf);
        }

Thanks,
Anil



--
Sent from: https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgstreamer-devel.966125.n4.nabble.com%2F&amp;data=04%7C01%7C%7C24ac24cc2a714dd7d77908d8df205ed6%7C28042244bb514cd680347776fa3703e8%7C1%7C1%7C637504677425205352%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=OUFd3lMBycgau%2B1AwMh43nFOhJXnJpgyyWETk0arEcs%3D&amp;reserved=0
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fgstreamer-devel&amp;data=04%7C01%7C%7C24ac24cc2a714dd7d77908d8df205ed6%7C28042244bb514cd680347776fa3703e8%7C1%7C1%7C637504677425215306%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=JwuxvprEHMH5Tqf79Ax8VBxcC4Ut1krEk5ln%2F6etqbc%3D&amp;reserved=0
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel