Problem with appsrc to x264enc
diyin
qgq1991 at 163.com
Mon May 20 00:32:55 UTC 2019
My requirement is generate h264 mp4 video from I420 raw data,
I have tested this pipline and it can work,
gst-launch-1.0 multifilesrc location=%04d.yuv ! videoparse format=2
width=3392 height=2008 framerate=25/1 ! videoconvert ! videorate ! x264enc !
mp4mux ! filesink location=out.mp4
But when I use appsrc to replace the multifilesrc in my gst-app,it dose not
work
luanch_src << "appsrc ! videoparse format=2 width=3392 height=2008
framerate=25/1 ! videoconvert ! videorate ! x264enc ! mp4mux ! filesink
location=ww.mp4";
Here is my push buffer code:
static GstFlowReturn new_sample (GstElement *sink, CustomData *data) {
GstSample *sample;
/* Retrieve the buffer */
g_signal_emit_by_name (sink, "pull-sample", &sample);
if (sample) {
GstBuffer *buffer_sink = gst_sample_get_buffer(sample);
GstMemory *memory = gst_buffer_get_memory(buffer_sink, 0);
GstMapInfo info;
gst_memory_map(memory, &info, GST_MAP_READ);
if (data->sample_num >= 150)
{
GstBuffer *buffer_src = gst_buffer_copy_deep(buffer_sink);
GST_BUFFER_PTS(buffer_src) = gst_util_uint64_scale (data->sample_num
- 150, GST_SECOND, 25);
GST_BUFFER_TIMESTAMP (buffer_src) = gst_util_uint64_scale
(data->sample_num - 150, GST_SECOND, 25);
GST_BUFFER_DURATION (buffer_src) = gst_util_uint64_scale (1,
GST_SECOND, 25);
gst_app_src_push_buffer((GstAppSrc*)data->app_src, buffer_src);
}
gst_memory_unmap(memory, &info);
gst_memory_unref(memory);
gst_sample_unref (sample);
data->sample_num++;
return GST_FLOW_OK;
}
Is there anything wrong?
Any ideas。Thanks!
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
More information about the gstreamer-devel
mailing list