Seek in a filesink

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Seek in a filesink

Sebastian Billaudelle
Hi there!

I'm currently writing an application in the style of an old-fashioned dictaphone. Basically, the application uses a filesink to write recorded data to a file.

The application should have a button for "rewinding the tape" and anotherone for fast-forwarding it. After pressing the "record"-button, the application should start recording from the new position.

Here is a little example:

The app recorded the following:

time: 1       2       3       4       5
data: bla bla bla bla bla bla foo foo foo foo

The user rewinds 3 seconds and goes on recording "bar":

time: 1       2       3       4       5
data: bla bla bla bla bar bar bar bar bar bar

=> It overwrites the previous recorded stuff.

I tried to do so by using gst.Element.seek_simple, but it returns False...

Here is the relevant code:

The pipeline: "pulsesrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=/tmp/test.ogg"

The seeking stuff: self.pipeline.get_by_name('filesink0').seek_simple(gst.FORMAT_TIME, gst.SEEK_TYPE_SET, 3000)

Thanks in advance!
Sebastian Billaudelle
--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

------------------------------------------------------------------------------
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Seek in a filesink

Laszlo Pandy
The function returns False to indicate that the seek fails. The reason
it fails is because filesink knows nothing about the data it is
storing and does not know how to use FORMAT_TIME. If you perform a
seekon the filesink with FORMAT_BYTES it should succeed, however you
will more than likely get a slightly corrupt file unless you know the
location in bytes of all the audio frames and managed not to cut one
of them in half. As well, you will probably have problems with the
timestamps in the file being inconsistent.

I don't know of another way to do it with GStreamer but if you plan on
doing it this way I would suggest you try wavenc since with the WAV
format you can easily convert seconds to the position in bytes using
the sample rate and bit width.

Laszlo

On Wed, Jun 24, 2009 at 4:42 AM, <[hidden email]> wrote:

> Hi there!
>
> I'm currently writing an application in the style of an old-fashioned dictaphone. Basically, the application uses a filesink to write recorded data to a file.
>
> The application should have a button for "rewinding the tape" and anotherone for fast-forwarding it. After pressing the "record"-button, the application should start recording from the new position.
>
> Here is a little example:
>
> The app recorded the following:
>
> time: 1       2       3       4       5
> data: bla bla bla bla bla bla foo foo foo foo
>
> The user rewinds 3 seconds and goes on recording "bar":
>
> time: 1       2       3       4       5
> data: bla bla bla bla bar bar bar bar bar bar
>
> => It overwrites the previous recorded stuff.
>
> I tried to do so by using gst.Element.seek_simple, but it returns False...
>
> Here is the relevant code:
>
> The pipeline: "pulsesrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=/tmp/test.ogg"
>
> The seeking stuff: self.pipeline.get_by_name('filesink0').seek_simple(gst.FORMAT_TIME, gst.SEEK_TYPE_SET, 3000)
>
> Thanks in advance!
> Sebastian Billaudelle
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
>
> ------------------------------------------------------------------------------
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>

------------------------------------------------------------------------------
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Seek in a filesink

Sebastian Billaudelle
Thanks for your reply! I'll just try to implement it the way you described!

Sebastian

> The function returns False to indicate that the seek fails. The reason
> it fails is because filesink knows nothing about the data it is
> storing and does not know how to use FORMAT_TIME. If you perform a
> seekon the filesink with FORMAT_BYTES it should succeed, however you
> will more than likely get a slightly corrupt file unless you know the
> location in bytes of all the audio frames and managed not to cut one
> of them in half. As well, you will probably have problems with the
> timestamps in the file being inconsistent.
>
> I don't know of another way to do it with GStreamer but if you plan on
> doing it this way I would suggest you try wavenc since with the WAV
> format you can easily convert seconds to the position in bytes using
> the sample rate and bit width.
>
> Laszlo
>
> On Wed, Jun 24, 2009 at 4:42 AM, <[hidden email]> wrote:
> > Hi there!
> >
> > I'm currently writing an application in the style of an old-fashioned
> dictaphone. Basically, the application uses a filesink to write recorded data
> to a file.
> >
> > The application should have a button for "rewinding the tape" and
> anotherone for fast-forwarding it. After pressing the "record"-button, the
> application should start recording from the new position.
> >
> > Here is a little example:
> >
> > The app recorded the following:
> >
> > time: 1       2       3       4       5
> > data: bla bla bla bla bla bla foo foo foo foo
> >
> > The user rewinds 3 seconds and goes on recording "bar":
> >
> > time: 1       2       3       4       5
> > data: bla bla bla bla bar bar bar bar bar bar
> >
> > => It overwrites the previous recorded stuff.
> >
> > I tried to do so by using gst.Element.seek_simple, but it returns
> False...
> >
> > Here is the relevant code:
> >
> > The pipeline: "pulsesrc ! audioconvert ! vorbisenc ! oggmux ! filesink
> location=/tmp/test.ogg"
> >
> > The seeking stuff:
> self.pipeline.get_by_name('filesink0').seek_simple(gst.FORMAT_TIME, gst.SEEK_TYPE_SET, 3000)
> >
> > Thanks in advance!
> > Sebastian Billaudelle
> > --
> > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> > Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> >
> >
> ------------------------------------------------------------------------------
> > _______________________________________________
> > gstreamer-devel mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >
>
> ------------------------------------------------------------------------------
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

------------------------------------------------------------------------------
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel