RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
Use ffmpeg and openbox root menu (schema.pl) to record any output from your sound card: http://lxlinux.com/ffmpeg.html .
Re: RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
nice, thanks.
so this is the line to record whichever audio that my machine is playing right now?
no errors, but it just records a silent track.
can you break it down for me?
afaics, '-i default' tells it where the sound comes from.
not sure what 'default' is.
i'm using plain alsa - maybe it works on pulseaudio?
aside:
"$(shuf -i 1-10000 -n 1)" is inelegant.
in case like these i like to use "$(date +%s)" - always unique and in temporary sequential order.
but maybe the actual date would be even more descriptive: "$(date +%Y-%m-%d_%H-%M-%S)"...
so this is the line to record whichever audio that my machine is playing right now?
Code: Select all
ffmpeg -f alsa -ac 2 -i default -c:a libvorbis -f ogg -b:a 320k ~/Music/$(shuf -i 1-10000 -n 1).ogg
can you break it down for me?
afaics, '-i default' tells it where the sound comes from.
not sure what 'default' is.
i'm using plain alsa - maybe it works on pulseaudio?
aside:
"$(shuf -i 1-10000 -n 1)" is inelegant.
in case like these i like to use "$(date +%s)" - always unique and in temporary sequential order.
but maybe the actual date would be even more descriptive: "$(date +%Y-%m-%d_%H-%M-%S)"...
Re: RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
(1) Do you have the necessary codecs installed: libvorbis for .ogg and libmp3lame for .mp3? The Sparky Linux Codec package has both. I presume your player is also properly equipped. Also presume you didn't get playback recording mp3.
(2) You can try substituting "pulse" for "alsa" in the commands, but unlikely to help.
(3) Did you upgrade your "ffmpeg", that is, getting the latest version of ffmpeg and ffprobe from http://ffmpeg.gusari.org/static/64bit/ as I suggested in the text of the article?
(4) "i" is "input device", and depends upon many things and can be changed to accommodate what you want to record down to the input to a single speaker in a multi-speaker system, for example, with a 7-way external speaker system. The "catch-all" is to just enter "default", and it will usually work. To see what audio devices are on your computer, put aplay -l into your terminal. Mine looks like the following:
From this information, there are 2 levels of input possible (in place of "-i default"). They are "-i hw:[card#]" or "-i hw:[card#,device#]". So in my computer with the "aplay -l" output above, all the following would be proper (but not necessarily productive): "-i hw:0"; "-i hw:2"; "-i hw:0,0"; "-i hw:0,1"; "-i hw:2,0"; "-i hw:2,1" . I suppose the computer hardware and installed audio software determine which and how these designations work. Even worse, these can change with a reboot, so they are not really that useful for a general script.
To get even more refined audio information about your computer and designations that are not suppose to change with every boot-up (unless you change the hardware), put "arecord -L" into your terminal. Here is the first few lines of mine (over 100 lines total which means like 50+ recording possibilities):
So, "default" is "Playback/recording through the PulseAudio sound server". Do you have "pulseaudio" installed? It appears "-i default" is the most sensible way to go. I have tried recording with many of these different settings, and the one that ALWAYS sounds closest to the original by my ears has been "-i default". So, no point in arguing with a simple solution when it is also the best solution.
(2) You can try substituting "pulse" for "alsa" in the commands, but unlikely to help.
(3) Did you upgrade your "ffmpeg", that is, getting the latest version of ffmpeg and ffprobe from http://ffmpeg.gusari.org/static/64bit/ as I suggested in the text of the article?
(4) "i" is "input device", and depends upon many things and can be changed to accommodate what you want to record down to the input to a single speaker in a multi-speaker system, for example, with a 7-way external speaker system. The "catch-all" is to just enter "default", and it will usually work. To see what audio devices are on your computer, put aplay -l into your terminal. Mine looks like the following:
Code: Select all
me@me-N76VJ:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC663 Analog [ALC663 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC663 Digital [ALC663 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: S51 [SB X-Fi Surround 5.1], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 2: S51 [SB X-Fi Surround 5.1], device 1: USB Audio [USB Audio #1]
Subdevices: 1/1
Subdevice #0: subdevice #0
To get even more refined audio information about your computer and designations that are not suppose to change with every boot-up (unless you change the hardware), put "arecord -L" into your terminal. Here is the first few lines of mine (over 100 lines total which means like 50+ recording possibilities):
Code: Select all
me@me-N76VJ:~$ arecord -L
default
Playback/recording through the PulseAudio sound server
null
.....
So, "default" is "Playback/recording through the PulseAudio sound server". Do you have "pulseaudio" installed? It appears "-i default" is the most sensible way to go. I have tried recording with many of these different settings, and the one that ALWAYS sounds closest to the original by my ears has been "-i default". So, no point in arguing with a simple solution when it is also the best solution.
Re: RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
are you sure this is going to work on a pure alsa setup?
no matter what, i get no errors, but it records only silence.
i tried substituting default with sysdefault, front, hw:0 ... and i have only one soundcard in there and it's a pretty normal intel chip and of course it works otherwise.
output from last try:
no matter what, i get no errors, but it records only silence.
i tried substituting default with sysdefault, front, hw:0 ... and i have only one soundcard in there and it's a pretty normal intel chip and of course it works otherwise.
output from last try:
Code: Select all
$> ffmpeg -f alsa -ac 2 -i hw:0 -c:a libvorbis -f ogg -b:a 320k ~/Music.ogg
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.1 (GCC) 20170109
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'hw:0':
Duration: N/A, start: 1488229288.818917, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
File '/home/mus/Music.ogg' already exists. Overwrite ? [y/N] y
Output #0, ogg, to '/home/mus/Music.ogg':
Metadata:
encoder : Lavf57.56.101
Stream #0:0: Audio: vorbis (libvorbis), 48000 Hz, stereo, fltp, 320 kb/s
Metadata:
encoder : Lavc57.64.101 libvorbis
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
[alsa @ 0x55933196ca40] ALSA buffer xrun.
size= 682kB time=00:00:25.48 bitrate= 219.1kbits/s speed=1.25x
video:0kB audio:674kB subtitle:0kB other streams:0kB global headers:4kB muxing overhead: 1.089988%
Re: RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
Did you get the latest version of ffmpeg from the source I indicated? The repositories apparently only have old versions that do not work for a lot of things. Just do the last download on the list in the link. Open it and move or copy ffmpeg and ffprobe to /usr/bin/ replacing the old ones. Make sure new ones are executable.
Otherwise, I do not know what you are missing. I have 2 basic openbox set-ups, one starting with Icebox and one starting with Sparky Linux Base - both very simple regarding what they contain, and set-up as described on my website. It works with both of those using the upgraded ffmpeg.
One other thing you could try. Install alsamixer, choose default audio card and then be sure the appropriate volumes are turned up for the capture mode (F4).
Otherwise, I do not know what you are missing. I have 2 basic openbox set-ups, one starting with Icebox and one starting with Sparky Linux Base - both very simple regarding what they contain, and set-up as described on my website. It works with both of those using the upgraded ffmpeg.
One other thing you could try. Install alsamixer, choose default audio card and then be sure the appropriate volumes are turned up for the capture mode (F4).
Re: RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
Just reread more carefully your command structure as described in your last post. You have the output going to "~/Music.ogg", which apparently confused ffmpeg, because she asks if you mean "File: /home/mus/Music.ogg already exists. Overwrite ?" Maybe she quit without heeding your answer?? Or maybe it is in your home folder as Music.org like you stipulated?
Re: RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
i tried it with the version from here: http://ffmpeg.gusari.org/static/64bit/f ... est.tar.gz
which is from 2014 (ffmpeg from the archlinux repos is from 2017).
now i get this:
which is from 2014 (ffmpeg from the archlinux repos is from 2017).
now i get this:
Code: Select all
$> ffmpeg -f alsa -ac 2 -i default -c:a libvorbis -f ogg -b:a 320k ~/Music/$(shuf -i 1-10000 -n 1).ogg
ffmpeg version N-63893-gc69defd Copyright (c) 2000-2014 the FFmpeg developers
built on Jul 16 2014 05:38:01 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 89.100 / 52. 89.100
libavcodec 55. 66.101 / 55. 66.101
libavformat 55. 43.100 / 55. 43.100
libavdevice 55. 13.101 / 55. 13.101
libavfilter 4. 8.100 / 4. 8.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Unknown input format: 'alsa'
Re: RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
Try these:
.
Just to further test your ffmpeg (nothing needs to be playing; it records the radio stream directly):
Code: Select all
ffmpeg -f pulse -ac 2 -i default -c:a flac -f flac ~/Music/$(shuf -i 1-10000 -n 1).flac
Code: Select all
ffmpeg -f alsa -ac 2 -i default -c:a libmp3lame -f mp3 -b:a 320k ~/Music/$(shuf -i 1-10000 -n 1).mp3
Just to further test your ffmpeg (nothing needs to be playing; it records the radio stream directly):
Code: Select all
ffmpeg -y -i http://8.38.78.173:8093/stream -c:a copy ~/Music/$(shuf -i 1-10000 -n 1).mp3
Re: RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
Code: Select all
$> ffmpeg -f pulse -ac 2 -i default -c:a flac -f flac ~/$(date +%s).flac
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.1 (GCC) 20170109
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
default: No such process
$> ffmpeg -f alsa -ac 2 -i default -c:a libmp3lame -f mp3 -b:a 320k ~/$(date +%s).mp3
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.1 (GCC) 20170109
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, alsa, from 'default':
Duration: N/A, start: 1488618833.812275, bitrate: 1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Output #0, mp3, to '/home/mus/1488618834.mp3':
Metadata:
TSSE : Lavf57.56.101
Stream #0:0: Audio: mp3 (libmp3lame), 48000 Hz, stereo, s16p, 320 kb/s
Metadata:
encoder : Lavc57.64.101 libmp3lame
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
size= 218kB time=00:00:05.52 bitrate= 322.8kbits/s speed=0.996x
video:0kB audio:217kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.453193%
$> ffmpeg -y -i http://8.38.78.173:8093/stream -c:a copy ~/$(date +%s).mp3
ffmpeg version 3.2.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.3.1 (GCC) 20170109
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-netcdf --enable-shared --enable-version3 --enable-x11grab
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Input #0, mp3, from 'http://8.38.78.173:8093/stream':
Metadata:
icy-notice1 : <BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>
icy-notice2 : SHOUTcast DNAS/posix(linux x64) v2.5.1.724<BR>
icy-name : Audiophile Classical
icy-genre : Classical, Classical, Chamber
icy-br : 320
icy-sr : 44100
icy-url : http://stream.psychomed.gr
icy-pub : 1
StreamTitle : Erno Dohnanyi - Symphony No. 1 in D minor, op.9, [BBC Philharmonic, Matthias Bamert]
Duration: N/A, start: 0.000000, bitrate: 320 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
Output #0, mp3, to '/home/mus/1488618852.mp3':
Metadata:
icy-notice1 : <BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>
icy-notice2 : SHOUTcast DNAS/posix(linux x64) v2.5.1.724<BR>
icy-name : Audiophile Classical
icy-genre : Classical, Classical, Chamber
icy-br : 320
icy-sr : 44100
icy-url : http://stream.psychomed.gr
icy-pub : 1
StreamTitle : Erno Dohnanyi - Symphony No. 1 in D minor, op.9, [BBC Philharmonic, Matthias Bamert]
TSSE : Lavf57.56.101
Stream #0:0: Audio: mp3, 44100 Hz, stereo, 320 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size= 550kB time=00:00:14.02 bitrate= 321.2kbits/s speed=2.03x
video:0kB audio:549kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.278988%
of the above command, the first produced an error and no output, the second produced a silent output file (and of course i have music playing meanwhile) and the third produces some classical music.
Re: RECORD ANYTHING FROM SOUND CARD IN 2 CLICKS
One of the problems with ffmpeg is that it has been in existence for a long time and has many developers, and so there are many versions available. You apparently have a later version than I do, but I seem to have more things configured, so I'll leave it to you to figure out what you need to configure to equal my version:
Let me know what you find.
By the way, all this ffmpeg activity has stimulated me to revise and upgrade my ffmpeg section of lxlinux.com: http://lxlinux.com/ffmpeg.html.
Code: Select all
me@me-N76VJ:~$ ffmpeg -version
ffmpeg version 3.0.7-0ubuntu0.16.10.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 6.2.0 (Ubuntu 6.2.0-5ubuntu12) 20161005
configuration: --prefix=/usr --extra-version=0ubuntu0.16.10.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint --enable-libx264
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
By the way, all this ffmpeg activity has stimulated me to revise and upgrade my ffmpeg section of lxlinux.com: http://lxlinux.com/ffmpeg.html.