[gst-devel] element seek and filesink
Sebastien Laporte
lapse at touchtunes.com
Mon Feb 13 11:50:09 CET 2006
Hi all,
I would like to have some insights on an application Im 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, Im 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 works correctly for an
alsasink but not for filesink.
Do I need to do something special to make it work with filesink? Im 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20060213/19b145de/attachment.htm>
More information about the gstreamer-devel
mailing list