I am trying to record what my device is currently playing using arecord (it is playing audio via mplayer).
I've done everything I have been able to read so far such as checking under which user mplayer is running, setting the user as per the command below, but it only ever records silence.
This is the list of users where my user is ID 1000:
user:x:1000:1000:,,,:/home/user:/bin/bash
This shows that what I am trying to record is running by that user:
user 1217 2.3 1.3 131704 25524 ? SL 09:11 12:15 /usr/bin/mplayer http://example.com/stream
This is the command I am running:
XDG_RUNTIME_DIR=/run/user/1000 /usr/bin/arecord -d 1 /home/user/rec.waw
The command will output:
Recording WAVE '/home/user/rec.waw' : Unsigned 8 bit, Rate 8000 Hz, Mono
And it writes the file, but the content is silent.
I have tried specifying --device but not sure how to specify it from the list of devices below (I tried --device=CARD=Headphones and --device=hw:CARD=Headphones but I get errors.
This is the output of arecord -L
user#device:~ $arecord -L
null
Discard all samples (playback) or generate zero samples (capture)
jack
JACK Audio Connection Kit
pulse
PulseAudio Sound Server
default
Playback/recording through the PulseAudio sound server
output
usbstream:CARD=b1
bcm2835 HDMI 1
USB Stream Output
usbstream:CARD=Headphones
bcm2835 Headphones
USB Stream Output
Any help would be appreciated.
Related
I am using arecord to record audio using a USB microphone that allows recording up to 384k sampling rate. With Audacity I can easily record with other lower sampling rates (48k, 44.1k ..) but when I use:
arecord -vD hw:4,0 -f S16_LE -d 120 -r 48000 -c 1 sample.wav
It displays a warning message:
Warning: rate is not accurate (requested = 48000Hz, got = 384000Hz)
And records with 384000Hz.
I can't get to fix this.
Edit: All of this was probably caused by a terribly configured microphone (or a faulty one, I changed laptops and now use Ubuntu instead of Arch Linux, so I actually don't have any idea). To record to a wav file, all I do now is run:
arecord -d $DURATION -f cd -t wav $OUTPUT_FILE_PATH
...replacing $DURATION with the duration of the recording in seconds, and $OUTPUT_FILE_PATH with the path to the desired file to write. I omitted the -D sysdefault argument as it caused problems for me (as with most things, your mileage may vary, so if the command doesn't work for you, try playing with several variables until it works).
Goes without saying, but all of this requires alsa-utils to be installed.
(The original question is left below, for those that still want to see it.)
Tl;dr version: arecord not recognizing plughw:1,0 , nor hw:1,0 , nor anything without the -D option
Whole story: I'm trying to make a simple voice assistant using a Bash script (I don't find Python/Perl easy for me to use, but that's just me). Dialogs are made in Zenity/KDialog. Voice recognition isn't included yet, so one has to type in the phrase/command. For now the program is represented in Spanish, but I plan to have an English version as well.
Doing my research, I found: http://blog.oscarliang.net/raspberry-pi-voice-recognition-works-like-siri/
But it doesn't work correctly on my machine.
[owner#arch-hp-2000-notebook-pc ~]$ ~/test-speech-input
“Recording… Press Ctrl+C to Stop.”
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM “plughw:1,0″
arecord: main:722: audio open error: No such file or directory
“Processing…”
^C
[owner#arch-hp-2000-notebook-pc ~]$
It apparently has to do with the arecord -D "plughw:1,0" -q -f cd -t wav part.
Output of arecord -l:
[owner#arch-hp-2000-notebook-pc ~]$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Generic_1 [HD-Audio Generic], device 0: ALC269VC Analog [ALC269VC Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
Output of arecord -L:
[owner#arch-hp-2000-notebook-pc ~]$
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
default
Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=Generic_1
HD-Audio Generic, ALC269VC Analog
Default Audio Device
front:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
Front speakers
surround21:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
[owner#arch-hp-2000-notebook-pc ~]$
Following the first part of the answer by #CharlesDuffy (thanks for the help):
[owner#arch-hp-2000-notebook-pc ~]$ ~/test-speech-input
Recording… Press Ctrl+C to Stop.
Processing…
You Said: [owner#arch-hp-2000-notebook-pc ~]$
Following the new answer, also by #CharlesDuffy (although this system is all AMD I think, no intel):
[owner#arch-hp-2000-notebook-pc ~]$ test-speech-input
Recording… Press Ctrl+C to Stop.
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM CARD=Generic_1
arecord: main:722: audio open error: No such file or directory
Processing…
You Said: [owner#arch-hp-2000-notebook-pc ~]$
Following the newest answer by #CharlesDuffy:
[owner#arch-hp-2000-notebook-pc ~]$
Recording… Press Ctrl+C to Stop.
ALSA lib pcm_dsnoop.c:614:(snd_pcm_dsnoop_open) unable to open slave
arecord: main:722: audio open error: No such file or directory
Processing…
^C
[owner#arch-hp-2000-notebook-pc ~]$
Double-checked the volume of the internal mic, and it seemed to have selected a non-existent mic. Switching to the real mic yielded the same results.
I'm lost right now. Any other ideas? Is there any other command-line voice recording tool that might work or that might be easier to use (at least for me)?
Machine: HP 2000 Notebook PC, Arch Linux, uname -a returns Linux HOST_NAME 4.1.2-2-ARCH #1 SMP PREEMPT Wed Jul 15 08:30:32 UTC 2015 x86_64 GNU/Linux
The plughw:1,0 suggestion is specific to Raspberry Pi hardware, and doesn't necessarily apply elsewhere.
The first thing I'd suggest is removing the -D DEVICE argument entirely.
If that doesn't work, I'd suggest trying:
-D sysdefault
...for your basic on-board audio, as listed by arecord -L.
i am totally new to pulse audio and alsa. the situation is this:
i have mpd compiled for alsa. this is embedded system and pulse audio plugin for mpd is not available.
when i DO NOT start pulse audio, mpd runs fine using alsa
as soon as i start pulse audio [ which is needed by bluetooth audio unfortunately ] , mpd / alsa stops working .
seems like, somehow pulse audio is grabbing the device and not letting it go . even after i stop pulse audio daemon .
Trying to run mpd afterwards gives me:
root#FINGI_GCC:~# mpc play
http://relay3.slayradio.org:8000/
[paused] #1/1 0:00/0:00 (0%)
volume:100% repeat: off random: off single: off consume: off
ERROR: problems opening audio device
So i was wondering how to reset pulse audio ? need to keep running pulse audio,mpd,alsa all on the same device..but not all at the same time.
Any suggestion on this?
Assuming this audio device in in /dev/snd/, you could try to see which process is holding it with:
lsof /dev/snd/*
Then you could try to kill this process.
For instance when I'm running alsamixer, I get:
$ lsof /dev/snd/*
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
...
alsamixer 7152 emilien 3u CHR 116,5 0t0 10154 /dev/snd/controlC0
...
I am struggling with getting mplayer to reproduce a 4 audio channel wav file.
I created a 4chn audio file.
Want mplayer to player, and output it to jack.
The problem is that i am only able to get in jack 2 mplayer channels.
if I do:
mplayer -ao jack -channels 4 test_4chan_2.wav
mplayer plays and responds:
laying test_4chan_2.wav.
libavformat version 54.6.100 (internal)
Audio only file format detected.
Load subtitles in ./
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 4 ch, s16le, 2822.4 kbit/100.00% (ratio: 352800->352800)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [jack] 44100Hz 2ch floatle (4 bytes per sample)
Video: no video
Starting playback...
and jack has only the following outputs:
system:capture_1
system:capture_2
system:playback_1
system:playback_2
MPlayer [14434]:out_0
MPlayer [14434]:out_1
So it seems that mplayer recognizes that the input file as 4ch
but on AO: [jack] only 2ch appear
if I try the same with ecasound:
ecasound -f 16,4,44100 -i test_4chan_2.wav -o jack
in Jack ecasoud appears with 4 outputs
system:capture_1
system:capture_2
system:playback_1
system:playback_2
ecasound:out_1
ecasound:out_2
ecasound:out_3
ecasound:out_4
Do you have any idea of what could I be doing wrong??
I am running Debian (Jessy) and mplayer 1.1-4.7
Thanks a lot
Solved. Only need to upgrade mplayer to 4.8, in Debian Sid.
And
mplayer -channels 4 -ao jack:noconnect 4chn_file.wav
did the trick.
The -ao jack:noconnect means:
-ao audio-output: jack
noconnect: prevent mplayer to make 1-to-1 connections. As I have 2 different stereo audio sound cards, mplayer was only giving me 2 channels. And this option disables that start behavior.
hope it will be of help to someone else ,)
I want to capture a image through webcam in linux.
So i searched on internet and found out it's can be done using mplayer or vlc.
Following is the command for capturing image by mplayer and its corresponding error.
[root#localhost ~]# mplayer -vo png -frames 1 tv://
MPlayer SVN-r31628-4.4.4 (C) 2000-2010 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing tv://.
TV file format detected.
Selected driver: v4l2
name: Video 4 Linux 2 input
author: Martin Olschewski <olschewski#zpr.uni-koeln.de>
comment: first try, more to come ;-)
v4l2: unable to open '/dev/video0': No such file or directory
v4l2: ioctl set mute failed: Bad file descriptor
v4l2: 0 frames successfully processed, 0 frames dropped.
Exiting... (End of file)
[root#localhost ~]#
Please Help me in solving this error.
I searched on net and found out about v4l2, but still can't solve the problem.
Your error is pretty clear. The webcam apparently is not registering at /dev/video0. In some instances, I've found that encoders or other video devices register under /dev/videoX, where X can be any integer. Try modifying your statement to try different video devices.
You can also try using fswebcam which has a useful feauture of skipping the first few frames
-some webcam show corrupt (or green) images for the first frame or two:
fswebcam --skip 2
It can be set to capture an image every second:
fswebcam --skip 2 --loop 1
I made it by doing this:
mplayer tv:// -tv driver=v4l2:device=/dev/video0 -fps 1 -frames 2 -sstep 100 -vo jpeg; rm 00000001.jpg ; mv 00000002.jpg capture.$(date +%F_%R).jpg.
where:
"tv:// -tv driver=v4l2:device=/dev/video0" specifies the necessary driver and video device. You need to check if that device is the one you want to capture and or exists by doing ls /dev/video*.
-fps 1 -frames 2 -sstep 100 specifies the framerate and it's set to only one per second to ensure you will have enough time to wake up properly the camera, captures 2 frames and in between frames you had 100 fps from the output dropped to help with the camera focus.
-vo jpeg stands for jpg output format images, on my computer png doesn't work with all this configuration.
rm 00000001.jpg deletes the first frame capture, because always it's ging to be obscure, green or no focused, this is caused by the small amount of time neede by the camera to wake up.
mv 00000002.jpg capture.$(date +%F_%R).jpg makes the second frame image switch name from 00000002.jpg for "capture." plus the current date time.