Keep multiple files AND merge into one file

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

Keep multiple files AND merge into one file

Ryan Dougher
Hi folks,
I have a dir which mp3s are regularly added to one at a time. Each time an mp3 is added, I would like to copy it onto the end of another file while keeping the separate files.

Ex:
1.mp3 shows up
  - add to end of master.mp3
2.mp3 shows up
  - add to end of master.mp3
3.mp3 shows up
  - add to end of master.mp3

Note that the files are added to the dir *one at a time*. So the first to show up is 1.mp3, which I would then run `sox 1.mp3 master.mp3` and the content of 1.mp3 would be copied to master.mp3. But then 2.mp3 shows up and I run `sox 2.mp3 master.mp3` and it overwrites master.mp3 with only the content of 2.mp3.

Is there any way to simply add each new file (one at a time, as they show up) to the end of master.mp3 *without* overwriting the previous content of the other mp3 files?

Thanks,
Ryan

------------------------------------------------------------------------------

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

Re: Keep multiple files AND merge into one file

Peter Shute
This sounds more like a problem of how to identify new files, rather than a sox problem.

If you were to move or rename each new file after adding it to master.mp3 then it would simplify that task because only the next new file would match the n.mp3 naming pattern.

Peter Shute

Sent from my iPad

> On 9 Jun 2015, at 1:54 pm, Ryan Dougher <[hidden email]> wrote:
>
> Hi folks,
> I have a dir which mp3s are regularly added to one at a time. Each time an mp3 is added, I would like to copy it onto the end of another file while keeping the separate files.
>
> Ex:
> 1.mp3 shows up
>   - add to end of master.mp3
> 2.mp3 shows up
>   - add to end of master.mp3
> 3.mp3 shows up
>   - add to end of master.mp3
>
> Note that the files are added to the dir *one at a time*. So the first to show up is 1.mp3, which I would then run `sox 1.mp3 master.mp3` and the content of 1.mp3 would be copied to master.mp3. But then 2.mp3 shows up and I run `sox 2.mp3 master.mp3` and it overwrites master.mp3 with only the content of 2.mp3.
>
> Is there any way to simply add each new file (one at a time, as they show up) to the end of master.mp3 *without* overwriting the previous content of the other mp3 files?
>
> Thanks,
> Ryan
> ------------------------------------------------------------------------------
> _______________________________________________
> Sox-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/sox-users

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

Re: Keep multiple files AND merge into one file

Erich Eckner
Hi,

since mp3 is a lossy format, I do not recommend encoding the same piece
of audio over and over again.
Rather just do
sox 1.mp3 2.mp3 ... n.mp3 master.mp3
or within linux' bash
sox {1..n}.mp3 master.mp3

This will create master.mp3 "from scratch", which will not add more and
more codec-based glitches.

greetings,
Erich

Am 09.06.2015 um 07:03 schrieb Peter Shute:

> This sounds more like a problem of how to identify new files, rather than a sox problem.
>
> If you were to move or rename each new file after adding it to master.mp3 then it would simplify that task because only the next new file would match the n.mp3 naming pattern.
>
> Peter Shute
>
> Sent from my iPad
>
>> On 9 Jun 2015, at 1:54 pm, Ryan Dougher <[hidden email]> wrote:
>>
>> Hi folks,
>> I have a dir which mp3s are regularly added to one at a time. Each time an mp3 is added, I would like to copy it onto the end of another file while keeping the separate files.
>>
>> Ex:
>> 1.mp3 shows up
>>   - add to end of master.mp3
>> 2.mp3 shows up
>>   - add to end of master.mp3
>> 3.mp3 shows up
>>   - add to end of master.mp3
>>
>> Note that the files are added to the dir *one at a time*. So the first to show up is 1.mp3, which I would then run `sox 1.mp3 master.mp3` and the content of 1.mp3 would be copied to master.mp3. But then 2.mp3 shows up and I run `sox 2.mp3 master.mp3` and it overwrites master.mp3 with only the content of 2.mp3.
>>
>> Is there any way to simply add each new file (one at a time, as they show up) to the end of master.mp3 *without* overwriting the previous content of the other mp3 files?
>>
>> Thanks,
>> Ryan
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Sox-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/sox-users
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Sox-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/sox-users
>


------------------------------------------------------------------------------

_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users

signature.asc (851 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Keep multiple files AND merge into one file

Fmiser
In reply to this post by Ryan Dougher
> Ryan wrote:
>
> I have a dir which mp3s are regularly added to one at a
> time. Each time an mp3 is added, I would like to copy it
> onto the end of another file while keeping the separate
> files.

> Is there any way to simply add each new file (one at a
> time, as they show up) to the end of master.mp3 *without*
> overwriting the previous content of the other mp3 files?

I use GNU/Linux and heavily use BASH - so if that's not your
platform, my idea may not help much.

My first thought is to use a shell script and write a
temporary file.  Concatenate the latest mp3 and master.mp3
and write temp-master.mp3.  The re-name/move temp-master.mp3
to overwrite master.mp3

However, mp3 is a lossy format and SoX _always_ re-encodes.
So every time the script runs there would be additional
losses.  Probably not too bad for 3 or 4 files - but if there
are 30 or 40 the early ones could be sounding pretty poor.

My system has a tool called "mp3join" that concatenates MP3
files without re-encoding.  That might be a better option.

-- fm

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

Re: Keep multiple files AND merge into one file

Jan Stary
In reply to this post by Ryan Dougher
On Jun 09 03:28:49, [hidden email] wrote:

> Hi folks,
> I have a dir which mp3s are regularly added to one at a time. Each time an
> mp3 is added, I would like to copy it onto the end of another file while
> keeping the separate files.
>
> Ex:
> 1.mp3 shows up
>   - add to end of master.mp3
> 2.mp3 shows up
>   - add to end of master.mp3
> 3.mp3 shows up
>   - add to end of master.mp3

Why do you need to do that, and for how long?
Surely this will produce a hard to maintain huge audio file
(which will outgrow your disk one day).

Is the interval predictable, e.g. does the new file
appear every morning? Every whole hour? Every ten seconds?

Are the new files always names sequentially like in your example,
so that the new file is always named N.mp3 (or NNNNNNN.mp3)?

Are the coming files always in the same format?
Do you also need master.mp3 to be in that same format?

Do the individual files need to stay in that same directory,
after they are appended to the master?

> Note that the files are added to the dir *one at a time*. So the first to
> show up is 1.mp3, which I would then run `sox 1.mp3 master.mp3` and the
> content of 1.mp3 would be copied to master.mp3. But then 2.mp3 shows up and
> I run `sox 2.mp3 master.mp3` and it overwrites master.mp3 with only the
> content of 2.mp3.

Well, that's exactly what the command tells SoX to do.

> Is there any way to simply add each new file (one at a time, as they show
> up) to the end of master.mp3 *without* overwriting the previous content of
> the other mp3 files?

Yes. But reencoding mp3's over and over
will gradually degrade the sound quality.

Let's see the big picture first.


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

Re: Keep multiple files AND merge into one file

Ryan Dougher
In reply to this post by Erich Eckner
Erich,
Thanks for your suggestion, and I understand I don't want to encode the same piece over and over again.

My problem with running `sox 1.mp3 2.mp3 master.mp3` is that the separate smaller files are not all available at the same time.

I have the following sox command to record transmissions from an online fire/ambulance stream:

sox http://audio2.radioreference.com/303085458.mp3 ~/transmissions/tx.mp3 silence 1 1.2 0.5% 1 0.05 0.5% : newfile : restart

This creates a new tx001.mp3, tx002.mp3 tx.003.mp3, etc. every time there is a transmission on the stream.

What I want to be able to do is keep these separate transmissions files, but every time a new one is created, add its audio to the end of a master.mp3 file which contains all of the transmissions in one larger file.

My purpose for this is to use something like wavesurfer.js (http://www.wavesurfer.fm/) in order to visualize and navigate through a day's worth of transmissions. The problem with wavesurfer is that it appears to only take 1 audio file. I cannot use an array of files for one visualization.

So my hope was to keep the individual files for other purposes, but simultaneously add each new transmission to a separate master.mp3 file which could then be loaded into wavesurfer.

Ryan

On Tue, Jun 9, 2015 at 1:46 AM Erich Eckner <[hidden email]> wrote:
Hi,

since mp3 is a lossy format, I do not recommend encoding the same piece
of audio over and over again.
Rather just do
sox 1.mp3 2.mp3 ... n.mp3 master.mp3
or within linux' bash
sox {1..n}.mp3 master.mp3

This will create master.mp3 "from scratch", which will not add more and
more codec-based glitches.

greetings,
Erich

Am 09.06.2015 um 07:03 schrieb Peter Shute:
> This sounds more like a problem of how to identify new files, rather than a sox problem.
>
> If you were to move or rename each new file after adding it to master.mp3 then it would simplify that task because only the next new file would match the n.mp3 naming pattern.
>
> Peter Shute
>
> Sent from my iPad
>
>> On 9 Jun 2015, at 1:54 pm, Ryan Dougher <[hidden email]> wrote:
>>
>> Hi folks,
>> I have a dir which mp3s are regularly added to one at a time. Each time an mp3 is added, I would like to copy it onto the end of another file while keeping the separate files.
>>
>> Ex:
>> 1.mp3 shows up
>>   - add to end of master.mp3
>> 2.mp3 shows up
>>   - add to end of master.mp3
>> 3.mp3 shows up
>>   - add to end of master.mp3
>>
>> Note that the files are added to the dir *one at a time*. So the first to show up is 1.mp3, which I would then run `sox 1.mp3 master.mp3` and the content of 1.mp3 would be copied to master.mp3. But then 2.mp3 shows up and I run `sox 2.mp3 master.mp3` and it overwrites master.mp3 with only the content of 2.mp3.
>>
>> Is there any way to simply add each new file (one at a time, as they show up) to the end of master.mp3 *without* overwriting the previous content of the other mp3 files?
>>
>> Thanks,
>> Ryan
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Sox-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/sox-users
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Sox-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/sox-users
>


------------------------------------------------------------------------------
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users

------------------------------------------------------------------------------

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

Re: Keep multiple files AND merge into one file

Ryan Dougher
In reply to this post by Jan Stary
Jan,
Thanks for the reply. Please see my reply to Erich. Hopefully that will clear up what I'm trying to accomplish.

In reply to one of your concerns, yes, the master.mp3 file would only be for *one* day's worth of transmissions, so the file should not get to uncontrollably large (the stream is not very active).

I currently have a bash script which watches the transmissions directory and for every new file it renames the file based on modification date and moves it into a new dir based on the day's date.

Ryan

On Tue, Jun 9, 2015 at 11:55 AM Jan Stary <[hidden email]> wrote:
On Jun 09 03:28:49, [hidden email] wrote:
> Hi folks,
> I have a dir which mp3s are regularly added to one at a time. Each time an
> mp3 is added, I would like to copy it onto the end of another file while
> keeping the separate files.
>
> Ex:
> 1.mp3 shows up
>   - add to end of master.mp3
> 2.mp3 shows up
>   - add to end of master.mp3
> 3.mp3 shows up
>   - add to end of master.mp3

Why do you need to do that, and for how long?
Surely this will produce a hard to maintain huge audio file
(which will outgrow your disk one day).

Is the interval predictable, e.g. does the new file
appear every morning? Every whole hour? Every ten seconds?

Are the new files always names sequentially like in your example,
so that the new file is always named N.mp3 (or NNNNNNN.mp3)?

Are the coming files always in the same format?
Do you also need master.mp3 to be in that same format?

Do the individual files need to stay in that same directory,
after they are appended to the master?

> Note that the files are added to the dir *one at a time*. So the first to
> show up is 1.mp3, which I would then run `sox 1.mp3 master.mp3` and the
> content of 1.mp3 would be copied to master.mp3. But then 2.mp3 shows up and
> I run `sox 2.mp3 master.mp3` and it overwrites master.mp3 with only the
> content of 2.mp3.

Well, that's exactly what the command tells SoX to do.

> Is there any way to simply add each new file (one at a time, as they show
> up) to the end of master.mp3 *without* overwriting the previous content of
> the other mp3 files?

Yes. But reencoding mp3's over and over
will gradually degrade the sound quality.

Let's see the big picture first.


------------------------------------------------------------------------------
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users

------------------------------------------------------------------------------

_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users