Hello,<div>Yes, your idea is pretty good. And it works very well with <span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">FLAC, WAV and MP3 encoders.</span></div>
<div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">The recorded files have correct length and the "silent" parts have gone when replayed.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">But AAC, OGG audio and SPX encoders (file formats) add the missing "silent" bits when replayed, even the file has been cut correctly. I usually replay my tests in Totem or RhythmBox.</div>
</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="background-color:rgb(255,255,255)"><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">
This is exactly the same result I got with the VADer filter. (ref. my previous posting).</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br></div><div>The pipeline has this format:<br style="color:rgb(0,0,0);font-family:arial;font-size:small">
pulsesrc device="xxx" <span style="color:rgb(0,0,0);font-family:arial;font-size:small">! level ! tee name=t ! queue ! fakesink t. ! queue ! valve ! encodebin ! filesink</span></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">
<br></div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Example1:</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">WAV encoder. This produces correct result.</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><span style="background-color:transparent">gchar *pipeline_cmd = g_strdup("pulsesrc name=source"</span></div></div><div><div>                                 " ! level name=level"</div>
<div>                                 " ! tee name=t"</div><div>                                 " ! queue"</div><div>                                 " ! fakesink t."</div><div>                                 " ! queue"</div>
<div>                                 " ! valve name=valve"</div><div>                                 " ! audioconvert"</div><div>                                 " ! wavenc"</div><div>                                  " ! filesink name=filesink");</div>
</div><div><br></div><div><br></div><div>Example2:</div><div>OGG audio. Filesize is correct, but this adds the silent bits when replayed. </div><div><div>gchar *pipeline_cmd = g_strdup("pulsesrc name=source"</div>
<div>                                 " ! level name=level"</div><div>                                 " ! tee name=t"</div><div>                                 " ! queue"</div><div>                                 " ! fakesink t."</div>
<div>                                 " ! queue"</div><div>                                 " ! valve name=valve"</div><div>                                 " ! audioconvert"</div><div>                                 " ! vorbisenc"</div>
<div>                                 " ! oggmux"</div><div>                                 " ! filesink name=filesink");</div></div><div><br></div><div>In the code I set:</div><div><div>g_object_set(G_OBJECT(valve), "drop", TRUE / FALSE , NULL);</div>
<div><br></div></div><div><b>Conclusion:</b></div><div>We have to understand that the pipeline and its elements have an internal clock.</div><div>In some audio formats (like: OGG, <span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">AAC, and SPX) this clock overrides the missing frames, thus adding silent bits to the media when replayed.</span></div>
<div><br>There are some functions that might adjust the clock.</div><div><br></div><div><div>gst_element_get_base_time(...) and gst_element_set_base_time(...)</div><div>gst_element_get_start_time(...) and gst_element_set_start_time(...)</div>
</div><div><br></div><div>Or:</div><div>GstEvent *segment = gst_event_new_new_segment(FALSE, 1.0, GST_FORMAT_TIME, g_start_time,  g_end_time, g_start_time);</div><div><div>ret = gst_pad_send_event(sinkpad , segment);</div>
<div><br></div></div><div>But I do not know these methods well.</div><div><br></div><div>Anyway, it's been an interesting ride so far, and new comments are still welcomed.</div><div>--------------------------</div><div>
<br></div><div>Tested formats from gconf-editor,  system -> gstreamer -> 0.10 -> audio -> profiles:</div><div>AAC: audio/x-raw-int,rate=44100,channels=2 ! faac profile=2 ! ffmux_mp4</div><div>FLAC: audio/x-raw-int,rate=44100,channels=2 ! flacenc name=enc</div>
<div>OGG: audio/x-raw-float,rate=44100,channels=2 ! vorbisenc name=enc quality=0.5 ! oggmux</div><div>MP3: audio/x-raw-int,rate=44100,channels=2 ! lamemp3enc name=enc target=0 quality=6 ! xingmux ! id3v2mux</div><div>WAV: audio/x-raw-int,rate=22050,channels=1 ! wavenc name=enc</div>
<div>SPX: audio/x-raw-int,rate=32000,channels=1 ! speexenc name=enc ! oggmux</div><div><br></div><div>Greetings</div><div>Alexander </div><div><br></div><div><div class="gmail_quote">On Sun, Sep 16, 2012 at 9:11 PM, Stefan Sauer <span dir="ltr"><<a href="mailto:ensonic@hora-obscura.de" target="_blank">ensonic@hora-obscura.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><div class="im">
    <div>You could do something like this:</div></div>
    autoaudiosrc ! level ! tee name=t ! queue ! autoaudiosink t. ! queue
    ! valve ! encodebin ! filesink<br>
    <br>
    when the level drops below a threshold, you close the valve and
    remember the position. When the level gets above the threshold
    again, you open he valve (and eventually push a newsegment event).<span class="HOEnZb"><font color="#888888"><br>
    <br>
    Stefan<br></font></span></div></blockquote><div> </div></div></div>