On Sep 04 17:26:47, normalper...@yhbt.net wrote:
> Jan Stary <h...@stare.cz> wrote:
> > On Sep 04 07:03:31, normalper...@yhbt.net wrote:
> > > Can you reproduce the issue by using a temporary file instead of a pipe?
> > > I strongly suspect this is OpenBSD-specific and only to pipes.
> > 
> > SoX refuses to make the temporary file:
> > 
> >   $ sox -n one.sox synth 4.145 sin 440 gain -6                      
> >   $ sox -n two.sox synth 5.325 sin 540 gain -6                      
> >   $ sox one.sox part.sox trim 0 -`soxi -D two.sox` 
> >   sox FAIL trim: Position 2 is before start of audio.
> > 
> > which probably is the right thing. But with the pipe,
> > it tries to go on, and crashes. Which might be a hint
> > that it really is a pipe problem (namely, trying to rewind a pipe)
> > and not a trim problem, right?
> 
> Right, it's a rewind pipe problem.  Btw, does specifying -t/-c/-b/-r
> for the pipe avoid the problem by avoiding the need to automatically
> detect filetype?

Ha, it does:

$ sox -V -t sox "|sox one.sox -p trim 0 -`soxi -D two.sox`" two.sox out.sox
sox:      SoX v14.4.1
sox INFO formats: detected file format type `sox'
sox FAIL trim: Position 2 is before start of audio.

Input File     : '|sox one.sox -p trim 0 -5.325000' (sox)
Channels       : 1
Sample Rate    : 48000
Precision      : 32-bit
Sample Encoding: 32-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no
Comment        : 'Processed by SoX'


Input File     : 'two.sox'
Channels       : 1
Sample Rate    : 48000
Precision      : 32-bit
Duration       : 00:00:05.33 = 255600 samples ~ 399.375 CDDA sectors
File Size      : 1.02M
Bit Rate       : 1.54M
Sample Encoding: 32-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no
Comment        : 'Processed by SoX'

sox INFO sox: Overwriting `out.sox'

Output File    : 'out.sox'
Channels       : 1
Sample Rate    : 48000
Precision      : 32-bit
Sample Encoding: 32-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no
Comment        : 'Processed by SoX'

sox INFO sox: effects chain: input        48000Hz  1 channels
sox INFO sox: effects chain: output       48000Hz  1 channels


So it avoids doing the rewind now that it knows the type,
correctly refuses to do the nonsensical trim,
and, formally speaking, does what the OP asked for:
when the first file is actually shorter,
the output consist entirely of the second file:

$ soxi -D one.sox two.sox out.sox  
4.145000
5.325000
5.325000


Anyway, we _do_ have a rewind_pipe() problem
on OpenBSD, right?

        Jan


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

Reply via email to