rendered paste body#include <glib.h>
#include <gst/gst.h>
#include <sys/types.h>
#include <dirent.h>
int jpg_filename_filter(const struct dirent *d)
{
char *ext;
ext = strrchr(d->d_name, '.');
if (ext && strncasecmp(ext, ".jpg", 4) == 0)
{
return 1;
}
return 0;
}
int main (int argc, char *argv[])
{
GstElement *pipeline;
GstElement *multifilesrc;
GstElement *jpegdec;
GstElement *theoraenc;
GstElement *oggmux;
GstElement *filesink;
GstPad *src;
GstPad *sink;
GList *locations;
struct dirent **names;
int number;
int i;
gst_init(&argc, &argv);
pipeline = gst_pipeline_new("pipeline");
locations = g_list_alloc();
if ((number = scandir(".", &names, jpg_filename_filter, alphasort)) < 1)
{
fprintf(stderr, "no names");
exit(1);
}
for (i = 0; i < number; i++)
{
g_list_append(locations, names[i]->d_name);
}
multifilesrc = gst_element_factory_make("multifilesrc", "multifilesrc");
g_object_set(G_OBJECT(multifilesrc), "locations", locations, NULL);
jpegdec = gst_element_factory_make("jpegdec", "jpegdec");
theoraenc = gst_element_factory_make("theoraenc", "theoraenc");
oggmux = gst_element_factory_make("oggmux", "oggmux");
filesink = gst_element_factory_make("filesink", "sink");
g_object_set(G_OBJECT(filesink), "location", "x.ogg", NULL);
gst_element_link_pads(multifilesrc, "src", jpegdec, "sink");
gst_element_link_pads(jpegdec, "src", theoraenc, "sink");
src = gst_element_get_pad(theoraenc, "src");
sink = gst_element_get_compatible_pad(oggmux, src);
gst_pad_link(src, sink);
gst_element_link_pads(oggmux, "src", filesink, "sink");
gst_bin_add_many(GST_BIN(pipeline), multifilesrc, jpegdec, theoraenc, oggmux, filesink, NULL);
gst_xml_write_file(GST_ELEMENT(pipeline), stdout);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline)));
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (pipeline));
exit(0);
}