Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to rec.audio.pro
Jonathan[_5_] Jonathan[_5_] is offline
external usenet poster
 
Posts: 62
Default Sox 14.3.1: How to trim specified amount of time off the end of a wav file?

Hi,

Sorry for this basic question, but is there a simple way to use the
trim function in Sox to remove a specified amount of time off the
*end* of a WAV file?
Let's say 2 seconds, for example.

Is it necessary to know exactly how far into the file you want to
start trimming, or is there a way to just plug in 2 seconds as a
parameter?
I have read the documentation, but I found it a bit confusing.

Thanks!
Jonathan
  #2   Report Post  
Posted to rec.audio.pro
Scott Dorsey Scott Dorsey is offline
external usenet poster
 
Posts: 16,853
Default Sox 14.3.1: How to trim specified amount of time off the end of a wav file?

In article ,
Jonathan wrote:
Hi,

Sorry for this basic question, but is there a simple way to use the
trim function in Sox to remove a specified amount of time off the
*end* of a WAV file?
Let's say 2 seconds, for example.

Is it necessary to know exactly how far into the file you want to
start trimming, or is there a way to just plug in 2 seconds as a
parameter?
I have read the documentation, but I found it a bit confusing.


sox infile outfile trim 0 0:0:2
--scott


--
"C'est un Nagra. C'est suisse, et tres, tres precis."
  #3   Report Post  
Posted to rec.audio.pro
Jonathan[_5_] Jonathan[_5_] is offline
external usenet poster
 
Posts: 62
Default Sox 14.3.1: How to trim specified amount of time off the end of awav file?

On Jun 16, 11:45*am, Jonathan wrote:
Hi,

Sorry for this basic question, but is there a simple way to use the
trim function in Sox to remove a specified amount of time off the
*end* of a WAV file?
Let's say 2 seconds, for example.

Is it necessary to know exactly how far into the file you want to
start trimming, or is there a way to just plug in 2 seconds as a
parameter?
I have read the documentation, but I found it a bit confusing.

Thanks!
Jonathan


To clarify...
I realize you can accomplish this if you use zero as the first
parameter, and then specify a start time to start trimming...
Just wondering if there's a way to supply only the amount of trim
time, which would be a little easier for me.
  #4   Report Post  
Posted to rec.audio.pro
Jonathan[_5_] Jonathan[_5_] is offline
external usenet poster
 
Posts: 62
Default Sox 14.3.1: How to trim specified amount of time off the end of awav file?

On Jun 16, 11:57*am, (Scott Dorsey) wrote:
In article ,

Jonathan wrote:
Hi,


Sorry for this basic question, but is there a simple way to use the
trim function in Sox to remove a specified amount of time off the
*end* of a WAV file?
Let's say 2 seconds, for example.


Is it necessary to know exactly how far into the file you want to
start trimming, or is there a way to just plug in 2 seconds as a
parameter?
I have read the documentation, but I found it a bit confusing.


sox infile outfile trim 0 0:0:2
--scott

--
"C'est un Nagra. C'est suisse, et tres, tres precis."


Thanks!
  #7   Report Post  
Posted to rec.audio.pro
alex alex is offline
external usenet poster
 
Posts: 180
Default Sox 14.3.1: How to trim specified amount of time off the endof a wav file?

Il 16/06/2011 17.58, Jonathan ha scritto:
To clarify...
I realize you can accomplish this if you use zero as the first
parameter, and then specify a start time to start trimming...
Just wondering if there's a way to supply only the amount of trim
time, which would be a little easier for me.


maybe you can use the "reverse" command twice...
  #8   Report Post  
Posted to rec.audio.pro
alex alex is offline
external usenet poster
 
Posts: 180
Default Sox 14.3.1: How to trim specified amount of time off the endof a wav file?

Il 22/06/2011 12.40, alex ha scritto:
Il 16/06/2011 17.58, Jonathan ha scritto:
To clarify...
I realize you can accomplish this if you use zero as the first
parameter, and then specify a start time to start trimming...
Just wondering if there's a way to supply only the amount of trim
time, which would be a little easier for me.


maybe you can use the "reverse" command twice...


like this:

sox infile.wav outfile.wav reverse trim 30 reverse

this will trim out the last 30 seconds of audio. A bit slow since the
program need to reverse the file twice but works lossly.

  #9   Report Post  
Posted to rec.audio.pro
Anahata Anahata is offline
external usenet poster
 
Posts: 378
Default Sox 14.3.1: How to trim specified amount of time off the end of awav file?

On Thu, 16 Jun 2011 08:58:59 -0700, Jonathan wrote:


To clarify...
I realize you can accomplish this if you use zero as the first
parameter, and then specify a start time to start trimming... Just
wondering if there's a way to supply only the amount of trim time, which
would be a little easier for me.


My understanding is that Scott's answer does this.
Looking back though, I have to agree the manual isn't too clear...

--
Anahata
--/-- http://www.treewind.co.uk
+44 (0)1638 720444

  #10   Report Post  
Posted to rec.audio.pro
alex alex is offline
external usenet poster
 
Posts: 180
Default Sox 14.3.1: How to trim specified amount of time off the endof a wav file?

Il 22/06/2011 14.46, alex ha scritto:
like this:

sox infile.wav outfile.wav reverse trim 30 reverse

this will trim out the last 30 seconds of audio. A bit slow since the
program need to reverse the file twice but works lossly.


hehe, sorry... LOSSLESSLY...


  #11   Report Post  
Posted to rec.audio.pro
Nil Nil is offline
external usenet poster
 
Posts: 293
Default Sox 14.3.1: How to trim specified amount of time off the end of a wav file?

On 22 Jun 2011, anahata wrote in
rec.audio.pro:

man soxeffect

"trim start [length]
Trim can trim off unwanted audio from the beginning and end of
the audio. Audio is not sent to the output stream until the
start location is reached.

The optional length parameter tells the number of samples to
output after the start sample and is used to trim off the back
side of the audio. ***Using a value of 0 for the start
parameter will allow trimming off the back side only.***"

I have to RTFM *every* time I use sox. It's very powerful, but
impossible to remember all the commands and variations thereof,
and there's nearly always some trial and error before I get it to
do what I want.


Yes, that's what the manual says, but it's language is a little
misleading. What it does is remove everything BUT the tail. At least
that's what's happening for me, with version 14.3.0 for Windows. The
command

sox test.wav test1.wav trim 0 5

....leaves me with only the last 5 seconds of the file, rather than
removing the last 5 seconds.
  #12   Report Post  
Posted to rec.audio.pro
Nil Nil is offline
external usenet poster
 
Posts: 293
Default Sox 14.3.1: How to trim specified amount of time off the end of a wav file?

On 22 Jun 2011, alex wrote in rec.audio.pro:

like this:

sox infile.wav outfile.wav reverse trim 30 reverse

this will trim out the last 30 seconds of audio. A bit slow since
the program need to reverse the file twice but works lossly.


You're right - I find that very recommendation in the manual:

"Unfortunately, you must know the length of the silence at the end of
your audio file to trim off silence reliably. A work around is to
use the silence effect in combination with the reverse effect. By
first reversing the audio, you can use the above-periods to reliably
trim all audio from what looks like the front of the file. Then
reverse the file again to get back to normal."

I just tried it and it seems to work perfectly.
  #13   Report Post  
Posted to rec.audio.pro
Jonathan[_5_] Jonathan[_5_] is offline
external usenet poster
 
Posts: 62
Default Sox 14.3.1: How to trim specified amount of time off the end of awav file?

On Jun 22, 12:31*pm, Nil wrote:
On 22 Jun 2011, anahata wrote in
rec.audio.pro:









man soxeffect


"trim start [length]
*Trim *can *trim off unwanted audio from the beginning and end of
*the audio. *Audio is not sent to the *output *stream *until *the
*start location is reached.


*The *optional *length *parameter *tells the number of samples to
*output after the start sample and is used to trim off *the *back
*side *of *the audio. ****Using a value of 0 for the start
*parameter will allow trimming off the back side only.***"


I have to RTFM *every* time I use sox. It's very powerful, but
impossible to remember all the commands and variations thereof,
and there's nearly always some trial and error before I get it to
do what I want.


Yes, that's what the manual says, but it's language is a little
misleading. What it does is remove everything BUT the tail. At least
that's what's happening for me, with version 14.3.0 for Windows. The
command

sox test.wav test1.wav trim 0 5

...leaves me with only the last 5 seconds of the file, rather than
removing the last 5 seconds.


Yeah...I discovered that
  #14   Report Post  
Posted to rec.audio.pro
alex alex is offline
external usenet poster
 
Posts: 180
Default Sox 14.3.1: How to trim specified amount of time off the endof a wav file?

Il 22/06/2011 18.39, Nil ha scritto:
On 22 Jun 2011, wrote in rec.audio.pro:

like this:

sox infile.wav outfile.wav reverse trim 30 reverse

this will trim out the last 30 seconds of audio. A bit slow since
the program need to reverse the file twice but works lossly.


You're right - I find that very recommendation in the manual:

"Unfortunately, you must know the length of the silence at the end of
your audio file to trim off silence reliably. A work around is to
use the silence effect in combination with the reverse effect. By
first reversing the audio, you can use the above-periods to reliably
trim all audio from what looks like the front of the file. Then
reverse the file again to get back to normal."

I just tried it and it seems to work perfectly.


really? i don't readed the manual, i just searched for a "reverse"
command...
i don't expected this situation to be explained in the man.
In scripting terms the most reliable workaround will be allowing some
"algebra" in the parameters like this: "trim (end-30)"...

regards
alex
  #15   Report Post  
Posted to rec.audio.pro
Nil Nil is offline
external usenet poster
 
Posts: 293
Default Sox 14.3.1: How to trim specified amount of time off the end of a wav file?

On 22 Jun 2011, alex wrote in rec.audio.pro:

"Unfortunately, you must know the length of the silence at the
end of your audio file to trim off silence reliably. A work
around is to use the silence effect in combination with the
reverse effect. By first reversing the audio, you can use the
above-periods to reliably trim all audio from what looks like the
front of the file. Then reverse the file again to get back to
normal."

I just tried it and it seems to work perfectly.


really? i don't readed the manual, i just searched for a "reverse"
command...
i don't expected this situation to be explained in the man.
In scripting terms the most reliable workaround will be allowing
some "algebra" in the parameters like this: "trim (end-30)"...


Yes, it's in there, although the description is for a slightly
different scenario. It describes using the "silence" command, which
supposedly will delete all silence at the end of the track (which may
be what the OP wants, anyway.) "Reverse" works with the "trim" command,
too - I tried it. The command line:

sox test.wav test1.wav reverse trim 10 reverse

....removes exactly the last 10 seconds of the file. I was worried that
the "reverse" command might do something negative to the file, but I
tested it by comparing a double-reversed version with the original, and
they are byte-for-byte identical.


  #16   Report Post  
Posted to rec.audio.pro
alex alex is offline
external usenet poster
 
Posts: 180
Default Sox 14.3.1: How to trim specified amount of time off the endof a wav file?

Il 23/06/2011 0.57, Nil ha scritto:
...removes exactly the last 10 seconds of the file. I was worried that
the "reverse" command might do something negative to the file, but I
tested it by comparing a double-reversed version with the original, and
they are byte-for-byte identical.

yes because sox, after the initial decoding (if the file is encoded),
will save temp pcm files and does not re-encode it on every passage.
This make the "double reverse" method completely lossless against the
single processing step of the trim command. Sadly, expecially on large
files, this will lead to a slower processing task because the temp files
will be written 3 times instead of 1.
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eliminating a specified amount of time from the beginning of a WAV orMP3 file Jonathan[_5_] Pro Audio 4 February 11th 11 03:20 PM
creating a time limited mp3 file vtxr1300 Pro Audio 4 December 5th 07 08:38 AM
SoX trim option for trim fix length on first of batch files [email protected] Pro Audio 1 November 22nd 07 05:02 PM
i was regaining to amount you some of my coastal voices E. Y. Prazeres Car Audio 0 November 14th 07 07:08 AM
If you had an endless amount of money... Yourrid Car Audio 7 February 27th 04 10:18 PM


All times are GMT +1. The time now is 09:20 AM.

Powered by: vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 AudioBanter.com.
The comments are property of their posters.
 

About Us

"It's about Audio and hi-fi"