[gst-devel] element seek and filesink
Stefan Kost
ensonic at hora-obscura.de
Mon Feb 13 12:18:05 CET 2006
Hi Sebastien,
its recommended to use gstreamer 0.10 when writing new applications. Still I
belive in 0.10 seeking do't work with filesink. I also like to know why:
a.) not implemented
b.) not planned
Stefan
Sebastien Laporte wrote:
> Hi all,
>
>
>
> I would like to have some insights on an application I’m trying to
> write. I have an app that decodes an MMP file and encodes it to an MP3
> file. I have the pipeline setup and everything works ok.
>
>
>
> Now, I’m trying to create only a snippet of that song, 30 seconds offset
> from the beginning of the MMP file for a 30 seconds length.
>
>
>
> To begin with, I initialize the pipeline and start it. Then I try to
> seek to 30 seconds into the song. It fails every time. It work’s
> correctly for an alsasink but not for filesink.
>
> Do I need to do something special to make it work with filesink? I’m
> using 0.8.10.
>
>
>
>
>
> #include <stdio.h>
>
> #include <gst/gst.h>
>
> #include <string.h>
>
>
>
> GstElement *pipeline,
>
> *source,
>
> *decrypter,
>
> *sink;
>
>
>
> int
>
> main(int argc, char *argv[])
>
> {
>
>
>
> gchar filename[32];
>
> gchar *ptr;
>
>
>
> gst_init(&argc, &argv);
>
> if(argc != 2) {
>
> g_print("Usage: %s <MMP filename>\n", argv[0]);
>
> return -1;
>
> }
>
>
>
> strcpy(filename, argv[1]);
>
> ptr = strstr(filename, ".");
>
> sprintf(ptr, ".MP3");
>
>
>
> pipeline = gst_pipeline_new("converter");
>
> source = gst_element_factory_make("filesrc", "file-source");
>
> g_object_set(G_OBJECT(source), "location", argv[1], NULL);
>
>
>
> decrypter = gst_element_factory_make("mmp", "mmp");
>
> g_object_set(G_OBJECT(decrypter),
>
> …
>
> NULL);
>
>
>
> sink = gst_element_factory_make("filesink", "file-sink");
>
> g_object_set(G_OBJECT(sink), "location", filename, NULL);
>
>
>
> gst_bin_add_many(GST_BIN(pipeline), source, decrypter, sink, NULL);
>
> gst_element_link_many(source, decrypter, sink, NULL);
>
> gst_element_set_state(pipeline, GST_STATE_PLAYING);
>
>
>
> if(!gst_element_seek(pipeline, GST_FORMAT_TIME | GST_SEEK_METHOD_SET
> | GST_SEEK_FLAG_FLUSH,30*GST_SECOND)){
>
> g_print("seek failed");
>
> }
>
>
>
> while(gst_bin_iterate(GST_BIN(pipeline)));
>
>
>
> gst_element_set_state(pipeline, GST_STATE_NULL);
>
> gst_object_unref(GST_OBJECT (pipeline));
>
>
>
> return 0;
>
> }
>
>
>
>
>
>
>
> Tx
>
>
>
> Sébastien Laporte
>
>
>
More information about the gstreamer-devel
mailing list