How to stop and restart writing to a filesink (while the pipeline is alive).

Alexander Botero alex.botero at gmail.com
Mon Sep 17 02:18:19 PDT 2012


Paddy: The file is corrupt is both (in all) cases. The file pointer jumps
randomly.

Ok, I moved on and started to play with the GstCutter and GstVader
elements. I found GstVader on the net.

The GstCutter element:
I tested the cutter-filter but I had problems settings the treshold (volume
treshold) for the silent parts. So I gave it up.

The GstVader element:
GstVader is an improved version of the GstCutter element. It is a VAD
(Voice Activity Detection) filter.
It does a very good job by filtering out the silent parts.
Please read below how to get the Vader element (1). It's a product of
Carnegie Mellon University, USA.

Here I tested the Vader element with AAC, OGG, SPX, FLAC, WAV and MP3
encoders.
I took the the encoder-fragments from the GNOME's configuration registry.
Start gconf-editor and browse to: system -> gstreamer -> 0.10 -> audio ->
profiles.

Webcam (and its microphone) made it easy to test the volume-level and
treshold values, so I set the device="xxxx" in the pipelines (2).

Testing AAC (cd quality, file extension: m4a):
$  gst-launch-0.10 -e
--gst-plugin-path=$HOME/TT2/gst-template/gst-plugin/src/.libs pulsesrc
device="alsa_input.usb-Creative_Technology_Ltd._VF0610_Live__Cam_Socialize_HD_091214_b_00556-02-HD.analog-mono"
! vader threshold=0.3 auto-threshold=true ! queue ! audioconvert !
audioresample ! audio/x-raw-int,rate=44100,channels=2 ! faac profile=2 !
ffmux_mp4 ! filesink location=test1.xxx

Testing OGG audio (cd quality, lossy. file extension: ogg)
$ gst-launch-0.10 -e
--gst-plugin-path=$HOME/TT2/gst-template/gst-plugin/src/.libs pulsesrc
device="alsa_input.usb-Creative_Technology_Ltd._VF0610_Live__Cam_Socialize_HD_091214_b_00556-02-HD.analog-mono"
! vader threshold=0.3 auto-threshold=true ! queue ! audioconvert !
audioresample ! audio/x-raw-float,rate=44100,channels=2 ! vorbisenc
name=enc quality=0.5 ! oggmux ! filesink location=test1.xxx

Testing SPX (voice, lossy. file extension: spx)
gst-launch-0.10 -e
--gst-plugin-path=$HOME/TT2/gst-template/gst-plugin/src/.libs pulsesrc
device="alsa_input.usb-Creative_Technology_Ltd._VF0610_Live__Cam_Socialize_HD_091214_b_00556-02-HD.analog-mono"
! vader threshold=0.3 auto-threshold=true ! queue ! audioconvert !
audioresample ! audio/x-raw-int,rate=32000,channels=1 ! speexenc name=enc !
oggmux ! filesink location=test1.xxx

Results for AAC, OGG audio and SPX:
GstVader filters out the silent parts and the filesize is correct, BUT
playback replays the silent parts again (because of its internal clock?).
Playback (in Totem) shows approximately the same media length (in seconds)
as the recording pipeline.
So in reality, these pipelines cut nothing.
------------------------------------------

Testing FLAC (cd quality,lossless. file extension: flac)
$ gst-launch-0.10 -e
--gst-plugin-path=$HOME/TT2/gst-template/gst-plugin/src/.libs pulsesrc
device="alsa_input.usb-Creative_Technology_Ltd._VF0610_Live__Cam_Socialize_HD_091214_b_00556-02-HD.analog-mono"
! vader threshold=0.3 auto-threshold=true ! queue ! audioconvert !
audioresample ! audio/x-raw-int,rate=44100,channels=2 ! flacenc name=enc !
filesink location=test1.xxx

Testing WAV (voice, lossless. file extension: wav)
$ gst-launch-0.10 -e
--gst-plugin-path=$HOME/TT2/gst-template/gst-plugin/src/.libs pulsesrc
device="alsa_input.usb-Creative_Technology_Ltd._VF0610_Live__Cam_Socialize_HD_091214_b_00556-02-HD.analog-mono"
! vader threshold=0.3 auto-threshold=true ! queue ! audioconvert !
audioresample ! audio/x-raw-int,rate=22050,channels=1 ! wavenc name=enc !
filesink location=test1.xxx

Testing MP3 (cd quality. file extension: mp3)
$ gst-launch-0.10 -e
--gst-plugin-path=$HOME/TT2/gst-template/gst-plugin/src/.libs pulsesrc
device="alsa_input.usb-Creative_Technology_Ltd._VF0610_Live__Cam_Socialize_HD_091214_b_00556-02-HD.analog-mono"
! vader threshold=0.3 auto-threshold=true ! queue ! audioconvert !
audioresample ! audio/x-raw-int,rate=44100,channels=2 ! lamemp3enc name=enc
target=0 quality=6 ! xingmux ! id3v2mux ! filesink location=test1.xxx

Result for FLAC, WAV and MP3:
The result is very good.
The GstVader filters out the silent parts and the filesize is correct.
Playback is also without the silent bits. O resultado muito bom!

For MP3, I noticed that the time-slider in Totem is a bit staccato at first
playback. It's smooth at repeated playback.
------------------------------------------

Question:
The AAC, OGG audio and SPX failed to produce a correct result. The files
(somehow) keep the silent parts even the file has been cut correctly.
I have tried to manipulate the filesink's internal clock without success.
Do you have any thoughts about this?
------------------------------------------

I will test GstTee and GstValve later on. Ok?
------------------------------------------

1) Getting the GstVader element:
I copied it from the pocketsphinx-snapshot package.
See http://cmusphinx.sourceforge.net/wiki/download/
Copyright (c) 1999-2010 Carnegie Mellon University.

First, I created a basic GstPlugin from a template.
Ref:
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/chapter-building-boiler.html#section-boiler-source
Then I copied pocketsphinx/src/gstvader.[ch] to the sample, and changed the
files.

Eg. I had to add plugin_init(GstPlugin * plugin) function and
GST_PLUGIN_DEFINE(...) macro to the gstvader.c.
I added also -lgstaudio-0.10 to the Makefile.am.
libgstvader_la_LIBADD = $(GST_LIBS) -lgstaudio-0.10

The modified source code is here:
http://www.futuredesktop.org/tmp/gst-plugin.tar.gz
Please respect the copyright notice (of Carnegie Mellon University) in the
files.

Compilation/linking put a dynamic library into gst-plugin/src/.libs/ folder.

Checking the library:
$ gst-inspect-0.10
$HOME/test/gst-template/gst-plugin/src/.libs/libgstvader.so

  Plugin Details:
  Name: vader
  Description:  Vader plugin
  Filename: /home/alex/test/gst-template/gst-plugin/src/.libs/libgstvader.so
  Version: 0.10.0
  License: LGPL
  Source module: vader-plugin-package
  Binary package: GStreamer
---------------

2) Listing audio devices
pactl list | grep -A2 'Source #' | grep 'Name: ' | cut -d" " -f2

-- end ---


On Fri, Sep 14, 2012 at 10:44 AM, Paddy <pat.blanchon at gmail.com> wrote:

> Are you switching between the two wav files, or one wav file & the
> fakesink,
> when you see the big file issue??
>
> I don't see anything obviously wrong from a quick glance at your code. You
> may want to try adding something like "audio/x-raw-int, rate= ..." after
> the
> audioconvert element. What does the debug reveal when you switch outputs ??
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20120917/159f1fd4/attachment-0001.html>


More information about the gstreamer-devel mailing list