Piping sox output into aplay - linux

I need to concat multiple mp3 files together then adjust there volume then play via aplay. I currently do this using the following 3 commands
sox file1.mp3 file2.mp3 file3.mp3 out1.wav
sox -v 0.5 out1.wav out2.wav
aplay -D plughw:1,0 out2.wav
This works correctly the only minor issue is it creates temporary files and I know it can be done by piping all these commands together somehow. Sort of like.
sox file1.mp3 file2.mp3 file3.mp3 | sox -v 0.5 | aplay -D plughw:1,0
But can't appear to get the piping to work (I am not really a linux user) Any help would be much appreciated :)

Related

Change audio format without changing audio from the command line

I have some audio recorded form an i2s mic at 16000hz with arecord. It sounds like it is down an octave so I want to change the file format to 32000hz. When I try to do this with sox it edits the audio, not just the format so it still sounds wrong.
This is the sox command I am using: sox in.wav -r 32000 out.wav What command should I use instead?
Looks like order matters in the command. The correct command is:
sox -r 32000 in.wav out.wav
If you want to change the audio rate, you can do it this way with ffmpeg:
ffmpeg -i input.wav -ar 32000 output.wav

Linux: How to combine multiple FLAC audio files into 1 file, with differing sample rates, but not changing pitch

I've looked everywhere to try to combine a bunch of FLAC files with differing sample rates into 1 file. What I've tried so far is:
ffmpeg concat with a wildcard:
ffmpeg -f concat -i <( for f in *.flac; do echo "file '$(pwd)/$f'"; done ) -safe 0 output.flac
I get for every filename, (even if I change pwd to './' for relative):
ffmpeg unsafe filename
Regardless of the file's filename.
I've tried sox:
sox *.flac output.flac
Which leads to:
sox FAIL sox: Input files must have the same sample-rate
I've even tried combining the two:
#!/usr/bin/env bash
set -eu
for i in *.flac *.ogg *.mp3
do
ffmpeg -i "$i" "$i.wav"
done
sox *.wav combined.wav
Same error as above.
Anyone have any tips? I'm sure that in some Windows program you can drag in 5 differing sound files and combine them with ease. Is there not a simple way to do this on linux cmdline?
safe 0 is a private option for the concat demuxer, so it has to appear before the input i.e. -f concat -safe 0 -i ...

pipe sox play command to stdout

So I'm currently trying to stream my microphone input from my raspberry pi (rasbian)
to some sort of network stream in order to receive it later on my phone.
In order to do this I use arecord -D plughw:1,0 -f dat -r 44100 | top pipe the soundstream from my usb-microphone to stdout which works fine as far as I can see but I needed it to be a bit louder so I can understand people standing far away from it .
So i piped it to the sox play command like this :
arecord -D plughw:1,0 -f dat -r 44100| play -t raw -b 16 -e signed -c 2 -v 7 -r 44100 - test.wav
(test.wav is just some random wav file id doesn't work without it and there is a whitespace between the - behind 44100 and test.wav because i think - is a seperate parameter:
SPECIAL FILENAMES (infile, outfile):
- Pipe/redirect input/output (stdin/stdout); may need -t
-d, --default-device Use the default audio device (where available))
I figured out by using the -v parameter i can increase the volume.
This plays the recorded stream to the speakers I connected to the raspberry pi 3 .
Final goal : pipe the volume increased soundstream to the stdout(or some fifopipe file) so i can get it from stdin inside another script to send it to my phone.
However im very confused by the manpage of the play command http://sox.sourceforge.net/sox.html
i need to select the outputdevice to pipe or stout or something
if you know a better way to just increase the voulme of the i think Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereosoundstream let me know
As far as I'm aware you can't pipe the output from play, you'll have to use the regular sox command for that.
For example:
# example sound file
sox -n -r 48k -b 16 test16.wav synth 2 sine 200 gain -9 fade t 0 0 0.1
# redundant piping
sox test16.wav -t wav - | sox -t wav - gain 8 -t wav - | play -
In the case of the command in your question it should be sufficient to change play to sox and add -t wav to let sox know in what format you want to pipe the sound.
arecord -D plughw:1,0 -f dat -r 44100 | \
sox -t raw -b 16 -e signed -c 2 -v 7 -r 44100 - -t wav -

Video quality when desktop recording is bad

Trying to record my desktop and also audio with RHEL6.
I'm using the command below, but the quality of the video output is not good.
It is very blurry and I can bearly make out text on screen.
The audio is good so no issues there.
Does anyone know how the make the video quality any better?
ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -r 25 -i :0.0 -sameq -f mpeg -ar 48000 -s wvga -y sample.avi
I believe the -sameq option means 'same quantizer' not 'same quality' and is depreciated, see here.
Try -q 1 instead.
q being quality 1-32 (1 being highest)

How to generate video screencaps of video files via linux commandline

Is there a command line program for linux (ubuntu) which can generate a large image containing say 6 caps from a given video (e.g. WMV) laid out storyboard style (I know on Windows media player classic can do this)? I need this for part of a script I am writing.
I pulled the answer from this site: http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/
ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
Where -4 is the number of seconds into the file to grab the screenshot, 320x240 is the screenshot size, and test.jpg is the output file.
Hope this helps.
Use SlickSlice
./slickslice.sh -x video.avi -s 5x3 -e
I've used MPlayer to save frames as images and ImageMagick to combine them:
mplayer -nosound -sstep 15 -vo png video.mkv
montage *.png -tile 3x3 -geometry 300x+0+0 screencaps.png
vcsi can do this. It is a command-line tool written in Python. Example:
vcsi video.mkv -o output.jpg

Resources