alternate two wav files into 1 single one using sox and bash - linux

I'm using linux and bash I have two files filea.wav and fileb.wav which are both 1 second long. I would like to join 4000 of them so I will get 1 large file that is an hour long that has the two files alternating.
Example: of what the 1 hour single file would look like
filea.wav fileb.wav filea.wav fileb.wav filea.wav fileb.wav .....
I know I can use sox to create and repeat a file
sox filea.wav file1hour.wav repeat 4000
but how can I have it so two files alternate back and forth and still get 1 single file using sox?

sox filea.wav fileb.wav long.wav
sox long.wav file1hour.wav repeat 1800
rm long.wav
More details on how to use sox(1): http://sox.sourceforge.net/sox.html

Related

Splitting large tar file into multiple tar files

I have a tar file which is 3.1 TB(TeraByte)
File name - Testfile.tar
I would like to split this tar file into 2 parts - Testfil1.tar and Testfile2.tar
I tried the following so far
split -b 1T Testfile.tar "Testfile.tar"
What i get is Testfile.taraa(what is "aa")
And i just stopped my command. I also noticed that the output Testfile.taraa doesn't seem to be a tar file when I do ls in the directory. It seems like it is a text file. May be once the full split is completed it will look like a tar file?
The behavior from split is correct, from man page online: http://man7.org/linux/man-pages/man1/split.1.html
Output pieces of FILE to PREFIXaa, PREFIXab, ...
Don't stop the command let it run and then you can use cat to concatenate (join) them all back again.
Examples can be seen here: https://unix.stackexchange.com/questions/24630/whats-the-best-way-to-join-files-again-after-splitting-them
split -b 100m myImage.iso
# later
cat x* > myImage.iso
UPDATE
Just as clarification since I believe you have not understood the approach. You split a big file like this to transport it for example, files are not usable this way. To use it again you need to concatenate (join) pieces back. If you want usable parts, then you need to decompress the file, split it in parts and compress them. With split you basically split the binary file. I don't think you can use those parts.
You are doing the compression first and the partition later.
If you want each part to be a tar file, you should use 'split' first with de original file, and then 'tar' with each part.

Mix and trim 2 files with Sox

I need a little bit help and hope to find that here.
I am using sox for tagging some music with voice tags on my server while user is uploading the file. This is my command which I was using. Everything is working fine.
sox -m {voice_tag_loop} {source_file} {output_file}
Now I want to change something, but don't know how to do that and find no solution.
So the {voice_tag_loop} will be uploaded by user and can have all length e.g. 30 seconds, 20s, 17s or 1 Minute. Don't know that before.
The {source_file} is the music file and can have also different length e.g. 3:13 Min, 4:20Min
How can I mix the {voice_tag_loop} with the {source_file} that the {output_file} has the length of {source_file} but has the {voice_tag_loop} is mixed and looped/ repeated into also with as long the length of the {source_file}
I hope I could explain that, that you can understand that.
Best regards
Just repeat until the source file is exhausted, e.g.:
sox -m "| sox {voice_tag_loop} -p repeat -" {source_file} trim 0 $(soxi -d {source_file})
NB, don't forget the trim bit, otherwise the repeat part will generate an infinite file.
OK I have now the answer for all you wants to mix short audio with long audio and the short one should repeated as long the long audio is.
In my case a small description. The short file will be changed to 44.1kHz and will be looped every 30 seconds. Max 100 times but as long as the long file is. And finally both files will be mixed. This all is one procedure.
sox {short_file} -r 44.1k -p pad 0 30 repeat 100 trim 0 $(sox --i -d {long_file}) | sox - -m {long_file} {output_file}
Regards
this did it for me
sox {short_file} -p repeat 100 trim 0 $(sox --i -d {long_file}) | sox - -m {long_file} {new_file}

run multiple commands in parallel in unix

I have few files and I have to cut few columns from that files to generate new files unix.
I tried to do it in loop as selecting files in directory and generating new files but as directory having 100 such files it takes lot of time to generate new files.
Can anyone please help if I can select 10 files in parallel and generate 10 new files and again next set of 10 files as it will reduce the time.
i need sample unix code block for this
cut -b 1-10,25-50,65-79 file1.txt > file_cut1.txt
cut -b 1-10,25-50,65-79 file2.txt > file_cut2.txt
You can do that quite simply with GNU Parallel like this:
parallel 'cut -b 1-10,25-50,65-79 {} > {.}_cut.txt' ::: file*txt
where:
{} represents the current filename, and
{.} represents the current filename without its extension.
Make a backup of the files in your directory before trying this, or any unfamiliar commands.
It will process your files in parallel, doing N at a time, where N is the number of cores in your CPU. If you want it to do, say 8, jobs at a time, use:
parallel -j 8 ...
If you want to see what it would do, without actually doing anything, use:
parallel --dry-run ...

Combining all the images in folder into a video

I have a script that takes tons of pictures and names them with a time-stamp. These Images are all put into one folder. I want to create a script that takes all the pictures in the folder, combines them into a 10fps video, saves this video as the date and time it started from to the time it ended, and deletes the original pictures. So far, I've seen some people use Ffmpeg or mencoder but I'm not sure how to use these or do what I want with them. Any help is appreciated! Thanks.
You can use the FFMpeg command line interface. You invoke it from the shell. Download the binary and run it by pointing it at the desired directory. %05d is simply string formatting for numbers. %05d just says pad with 4 leading zeros 0001.jpg or whatever.
# Create a directory and copy the original images there for manipulation:
mkdir temp
cp *.JPG temp/.
# Resize the images:
mogrify -resize 200x200 temp/*.JPG
# Create the morph images
convert temp/*.JPG -delay 10 -morph 5 temp/%05d.jpg
# Stitch them together into a video
ffmpeg -r 50 -qscale 2 -i temp/%05d.jpg output.mp4
from http://www.itforeveryone.co.uk/image-to-video.html

Mix audio files with an offset(at particular points) using SOX

I have two audio files one is 10 secs long and other is 17 secs long, I want to mix the files together so that the 17 sec file starts playing from the start, while the 10 sec file will start after 7 seconds into the 17seconds file.
How can I do this?
I followed this link, I also tried other commands mentioned in Sox FAQ, question number 7, but I am unable to mix two files by providing an offset, I also tried the command in command line and the error is same.
The error which I see is
option ` ' not recognized
and the command I used is
sox -m drums.wav "|sox beats.wav -p pad 1.5" out.wav
Edit: It seems to me that the pipe operator "|" is broken, how do I fix this?
My problem is exactly the same as mentioned in this forum
I think there's an issue with ".
Try
sox -m drums.wav '|sox beats.wav -p pad 1.5' out.wav

Resources