Skip to content

Instantly share code, notes, and snippets.

@Forzaferrarileo
Created January 6, 2015 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Forzaferrarileo/04f7b3229d94dd2ee6f9 to your computer and use it in GitHub Desktop.
Save Forzaferrarileo/04f7b3229d94dd2ee6f9 to your computer and use it in GitHub Desktop.
gst eos problem
#include <gst/gst.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
GstElement *pipeline, *source, *capsfilter, *h264parse, *mux, *sink, *encoder;
GstBus *bus;
GstMessage *msg;
GstPad *blockpad;
gst_init (NULL,NULL);
source = gst_element_factory_make("videotestsrc","source");
capsfilter = gst_element_factory_make("capsfilter","caps");
h264parse = gst_element_factory_make("h264parse","h264parse");
mux = gst_element_factory_make("mp4mux","mux");
sink = gst_element_factory_make("filesink","sink");
encoder = gst_element_factory_make("x264enc","encoder");
//g_object_set(source, "bitrate", 6000000, NULL);
//g_object_set(rtph264, "config-interval", 1, NULL);
//g_object_set(rtph264, "pt", 96 , NULL);
g_object_set(sink, "location" , "test.mp4",NULL);
g_object_set(capsfilter, "caps", gst_caps_new_simple("video/x-raw",
"width", G_TYPE_INT, 1280,
"height", G_TYPE_INT, 720,
"framerate", GST_TYPE_FRACTION, 30 , 1 ,NULL), NULL);
pipeline = gst_pipeline_new("test-pipeline");
gst_bin_add_many(GST_BIN(pipeline), source,capsfilter,encoder,h264parse,mux,sink,NULL);
gst_element_link_many(source,capsfilter,encoder,sink,NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
sleep(5);
gst_element_send_event(sink, gst_event_new_eos ());
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment