LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-04-2010, 09:09 AM   #1
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Rep: Reputation: 48
recording audio being played


I am using ubuntu 8.04 with GNOME.
I was listening to song in firefox
I thought if I give input to ffmpeg as /dev/dsp then i can catch audio.
I tried
$ffmpeg -f audio_device -i /dev/dsp -t 10 /tmp/record.wav
Output was

Code:
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-pp --enable-swscaler --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libogg --enable-libgsm --enable-dc1394 --disable-debug --enable-libmp3lame --enable-libfaadbin --enable-libfaad --enable-libfaac --enable-xvid --enable-x264 --enable-liba52 --enable-amr_nb --enable-amr_wb --enable-shared --prefix=/usr
  libavutil version: 1d.49.3.0
  libavcodec version: 1d.51.38.0
  libavformat version: 1d.51.10.0
  built on Mar 17 2009 21:37:49, gcc: 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
Input #0, audio_device, from '/dev/dsp':
  Duration: N/A, bitrate: N/A
  Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, 705 kb/s
File 'record.wav' already exists. Overwrite ? [y/N] y
Output #0, wav, to 'record.wav':
  Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, 705 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
size=    2585kB time=30.0 bitrate= 705.6kbits/s    
video:0kB audio:2585kB global headers:0kB muxing overhead 0.001662%
I get 30 second wav file with no sound
What I am doing wrong ?

Last edited by sumeet inani; 04-04-2010 at 09:34 AM.
 
Old 04-04-2010, 11:47 AM   #2
sonichedgehog
Member
 
Registered: Oct 2007
Location: London UK
Distribution: Fedora Core 17
Posts: 296

Rep: Reputation: 32
Might not be possible on your hardware- take a look at
http://www.linuxquestions.org/questi...output-778582/

I have used the recordmydesktop option but it provided only very faint audio. If you are getting a silent or buzzing wav file you might be getting only the data from your microphone.
 
Old 04-04-2010, 02:29 PM   #3
clifford227
Member
 
Registered: Dec 2009
Distribution: Slackware 14
Posts: 282

Rep: Reputation: 64
Audacity is pretty good at ripping sound, editing, and converting to .ogg/mp3
 
Old 04-05-2010, 01:02 AM   #4
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
here is my output of amixer
Code:
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 64
  Mono: Playback 64 [100%] [0.00dB] [off]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 64
  Mono:
  Front Left: Playback 64 [100%] [0.00dB] [on]
  Front Right: Playback 64 [100%] [0.00dB] [on]
Simple mixer control 'PCM',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 255 [100%] [0.00dB]
  Front Right: Playback 255 [100%] [0.00dB]
Simple mixer control 'Front',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 64
  Mono:
  Front Left: Playback 64 [100%] [0.00dB] [on]
  Front Right: Playback 64 [100%] [0.00dB] [on]
Simple mixer control 'Front Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 2
  Front Left: 2 [100%]
  Front Right: 2 [100%]
Simple mixer control 'Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 2
  Front Left: 0 [0%]
  Front Right: 0 [0%]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 31
  Front Left: Capture 1 [3%] [-15.00dB] [on]
  Front Right: Capture 1 [3%] [-15.00dB] [on]
Simple mixer control 'Capture',1
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 31
  Front Left: Capture 1 [3%] [-15.00dB] [on]
  Front Right: Capture 1 [3%] [-15.00dB] [on]
Simple mixer control 'Digital',0
  Capabilities: cvolume
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 120
  Front Left: Capture 60 [50%] [0.00dB]
  Front Right: Capture 60 [50%] [0.00dB]
Simple mixer control 'Input Source',0
  Capabilities: cenum
  Items: 'Mic' 'Front Mic' 'Line'
  Item0: 'Mic'
Simple mixer control 'Input Source',1
  Capabilities: cenum
  Items: 'Mic' 'Front Mic' 'Line'
  Item0: 'Mic'
Mine is 3GHz core2 duo not a netbook.
(1)I mean , How can I tell that my sound card has facility to send output to file or not ?

(2)Also if you have been able to record sound (not external but the one media player of OS plays or browser plays via flash) then please tell me the procedure. I like using commands to accomplish tasks. Mencoder & ffmpeg are powerful utilities , I believe. Just I don't know how to wield them ?

(3)I have also installed audacity. I will try it.

Last edited by sumeet inani; 04-05-2010 at 01:10 AM.
 
Old 04-06-2010, 05:53 PM   #5
sonichedgehog
Member
 
Registered: Oct 2007
Location: London UK
Distribution: Fedora Core 17
Posts: 296

Rep: Reputation: 32
I wasn't successful; but I suspect you have a chance because you have
Code:
Simple mixer control 'Input Source',1
  Capabilities: cenum
  Items: 'Mic' 'Front Mic' 'Line'
  Item0: 'Mic'
in your output. Mine was similar but did not include "line".
So when you use audacity you might also see "line" in your input options,mine had only "mic" and "front mic". Maybe that would let you record from your sound card.
I recorded faintly using "recordmydesktop", apt-get this if you want to play with it, gtk-recordmydesktop is the gui version.
I have answered this as though you just want to record whatever is playing through your soundcard,but you can use mplayer -dumpaudio [NAME OF FILE, USUALLY FLV] -dumpfile [NAME OF SOUND FILE] to rip sound track out of a flash video. youtube-dl will import the flv's from youtube. I'm sure there are loads of other tools out there.
 
Old 04-07-2010, 12:57 AM   #6
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
see next post.
Somehow same post got submitted twics.

Last edited by sumeet inani; 04-07-2010 at 01:00 AM.
 
Old 04-07-2010, 12:57 AM   #7
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
Thanks sonichedgehog.
i will report my results & problems in this thread.

Code:
mplayer -dumpstream LINK -dumpfile SAVE
works when you know the link & in that case one can also 'wget' it
but at http://music.guruji.com/redirects/re...i&weakresult=0 the song is played via flash player.
I saw that the song is not saved in disk or memory cache in firefox.
So i thought about recording output of sound card.
If you find another way to get this song. Please tell me.
 
Old 04-17-2010, 05:03 AM   #8
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
thank you clifford227
I have learned to use audacity to record after an hour of experimenting.
For benefit of all let me explain:(sonichedgehog , you can also try this)
i read http://wiki.audacityteam.org/wiki/Re...n_the_computer
Then I ran 'alsamixer' in terminal & adjusted gain of capture,front mic boost with input source as 'front mic' as follows.I listen via headphone.
Code:
master=headphone=PCM=100
front=0
front mic boost=50
mic boost=0
capture=87
digital=0
input source=front mic
Then press record button in audacity. I think the red line in record graph says excessive amplitude.

Last edited by sumeet inani; 04-21-2010 at 12:44 AM.
 
Old 04-17-2010, 06:45 PM   #9
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
Quote:
Originally Posted by sumeet inani View Post
I am using ubuntu 8.04 with GNOME.
I was listening to song in firefox
I thought if I give input to ffmpeg as /dev/dsp then i can catch audio.
I tried
$ffmpeg -f audio_device -i /dev/dsp -t 10 /tmp/record.wav
If you want to record audio with ffmpeg this is how it's done.

Code:
ffmpeg -f oss -i /dev/dsp -ac 2 out.wav
The output file will be 16 Bit stereo at 44100 Hz, CD quality.

If you want an mp3 file type

Code:
ffmpeg -f oss -i /dev/dsp -acodec libmp3lame -ar 44100 -ab 128k -ac 2 out.mp3
The file will be 16 bit stereo, 44100 Hz with a bitrate of 128k.

I use this method to record audio on sites where downloading is not possible.
To stop the recording, press the letter q. Or use can use the t switch to record up to a specific time. For example -t 60 will record 60 secords and end the recording.


There is a firefox extension called Downloadhelper. It can download videos and audio files from many websites. There will be a few exceptions.

https://addons.mozilla.org/en-US/firefox/addon/3006

PS: Youtube has videos on using Downloadhelper

- Cheers

Last edited by dv502; 04-17-2010 at 07:20 PM.
 
Old 04-18-2010, 12:11 AM   #10
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
Quote:
Originally Posted by sumeet inani View Post
thank you clifford227
I have learned to use audacity to record after an hour of experimenting.
For benefit of all let me explain
i read http://wiki.audacityteam.org/wiki/Re...n_the_computer
Then I ran 'alsamixer' in terminal & adjusted gain of capture,front mic boost with input source as 'front mic' .Then press record button in audacity. I think the red line in record graph says excessive amplitude so should be avoided by tuning.

Glad you got audacity to work for you. I am curios have you tried the ffmpeg code with the -f oss option?

The code has worked for me and I want to know if it has worked for you.

Last edited by dv502; 04-18-2010 at 12:12 AM.
 
Old 04-18-2010, 12:34 AM   #11
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 2,324
Blog Entries: 1

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
ffmpeg can be a bit complex as you sometimes need to specify input and output parameters, even if they are the same.

$ ffmpeg -f oss -ac 2 -ar 48000 -i /dev/dsp -ac 2 -ar 48000 -acodec pcm_s16le -y recorded.wav

(and press Q to stop the recording / or ^C, but better not for some filetypes that need extra info)

$ arecord -D hw:0 -t wav -f S16_LE -c 2 -r 48000 recorded.wav

(alsa's variant / ^C to stop)

$ rec -t wav -s -2 -c 2 -r 48000 recorded.wav

(sox's variant / ^C to stop)

And of course audacity, or something more native to linux like ardour.
 
Old 04-19-2010, 01:37 AM   #12
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
(2)thank you shadow 7
I ran
Code:
arecord -D hw:0 -t wav -f S16_LE -c 2 -r 48000 recorded.wav
Recording WAVE 'recorded.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
After 15 seconds pressed ctrl+c
Aborted by signal Interrupt...
Initially I got crackling noise but then I adjusted amplitude & gain via 'alsamixer' & now I get a nice recording.I was looking for default program in ubuntu 8.04 which can record (I had to install audacity though it can do a lot). This is great.Only the thing is 17second wav file occupied 3.1MB the conversion to ogg using ffmpeg cut it to 72KB.Default rate is 8000HZ.Isn't that enough ?

(3)I have noticed that no firefox addon can grab song from http://music.guruji.com/redirects/re...i&weakresult=0 Because the website plays song via flash player & song isn't stored in disk cache.Can you grab it ?

Last edited by sumeet inani; 04-20-2010 at 04:52 AM.
 
Old 04-19-2010, 07:08 AM   #13
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 2,324
Blog Entries: 1

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
At stereo, 16 bit, and 44.1kHz, you are at CD quality. Which runs about 700MB for 74 minutes. In terms of recording capacities I just call that 1GB per hour. Once you edit out tracks, convert them to other formats and such it pretty much is. For you 17 seconds and 3.1MB. Lets call that 20 seconds and 4MB. So, 12MB a minute, so 50 minutes and 600MB. Sounds about right.

8kHz? Most mics pick up in that 20Hz - 20kHz range. Human hearing tops around 25kHz IIRC. Varies between individuals and most cheap speakers have trouble reproducing above 16kHz. So basically 8kHz is NOT enough. But it depends, if we're talking man talking and no need for high quality, then 8kHz would suffice for say a college lecture, unless it's a lecture about music with samples. Otherwise you're in essence taking 1/5th the quality of the CD and compressing that into another format. For the top ten countdown, ICK... For Martha Stewart, it might make her sound more like a man. That female and baby screaming register is somewhere around 6kHz.

That site appears to be streaming and there's no /tmp/Flash* component like youtube and other media services. I can't think of any mms:// download / caching recorder off the top of my head. Other than capturing /dev/dsp directly. Sometimes about:cache and choosing RAM or DISK can lead you to an underlying .mp3 or similar, but it doesn't seem to be the case on this one. There was a player.php cached item and some guruji stuff. There is a couple .swf files related to the player, but that doesn't do much good for finding the underlying media component. And several .js files to hint at what type of fuel the player runs on and where it gets it. If that's in your skillset to decode.

So basically (from what I'd do given the above):

aumix
Set PCM (master vol) as the recording channel. This appears to be the only mixer I've found capable of setting that parameter (yet). amixer will verify, but I've found no way to directly mimic the results by other means. And set Master volume and PCM levels to about 50%. This will reduce what you actively hear on your speakers. But these settings are your gain settings for the PCM capture.
$ aumix -q
$ aumix -v 50 -w 50 -v R
$ aumix -q

then
$ arecord -t wav -f S16_LE -c 2 -r 44100 recorded.wav

mp3 is based off of CD quality input, so might as well give it CD quality. Note, that you can forgo -t wav and -f S16_LE and others with a shortcut -f cd with arecord.

as in:
$ arecord -f cd recorded.wav

then
$ ffmpeg -i recorded.wav -ac 2 -ar 44100 -ab 192k -acodec libmp3lame -y recorded.mp3
or
$ ffmpeg -i recorded.wav -ac 2 -ar 44100 -ab 192k -acodec vorbis -y recorded.ogg

The resulting ogg is about 1/5th the size of the mp3 in my case, but:
$ ffmpeg -i recorded.ogg
shows CD quality and other specs like 53kbps. Odd since I told it 192kbps.

so
$ ffmpeg -i recorded.wav -ac 2 -ar 44100 -ab 192k -acodec vorbis -aq 100 -y recorded.ogg
and ffmpeg -i shows 163kbps. And the .ogg is just a hair smaller than the mp3 file.

I do stuff like this to capture festival output all the time. I normally use lame to do the conversion.

$ lame -b 320 input.wav output.mp3

But that's generally a source only install and other non-default quirks.

HTH
 
Old 04-19-2010, 08:07 AM   #14
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
to shadow 7
I realized later that human sound is 20Hz-20KHz and by nyquist criterion the signal has to be sampled at twice the maximum frequency for reproducing it ao atleast 40KHz or more.
Regarding getting this song -> http://music.guruji.com/redirects/re...i&weakresult=0
I also thought of getting song from cache in firefox by noting file additions in memory & disk cache & concluded that swf part which is (maybe) skin of flash player gets downloaded only.
'-f cd' option in arecord saved typing.

Last edited by sumeet inani; 04-21-2010 at 12:09 AM.
 
Old 04-20-2010, 04:53 AM   #15
sumeet inani
Member
 
Registered: Oct 2008
Posts: 895
Blog Entries: 26

Original Poster
Rep: Reputation: 48
(1)to dv502
I ran
Code:
$ffmpeg  -f oss -i /dev/dsp -ac 2 out.wav
OUTPUT
FFmpeg version SVN-r17747, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-x11grab
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 0 / 52.20. 0
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  built on Apr 19 2010 14:04:07, gcc: 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
Input #0, oss, from '/dev/dsp':
  Duration: N/A, start: 1271679835.257636, bitrate: N/A
    Stream #0.0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
Output #0, wav, to 'out.wav':
    Stream #0.0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
size=    1479kB time=8.59 bitrate=1411.2kbits/s    
video:0kB audio:1479kB global headers:0kB muxing overhead 0.002905%
When I play out.wav it is blank i.e no sound ?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Podcast aggregator that automatically deletes played audio files? digby280 Linux - Software 2 05-04-2008 07:27 AM
Strange: Audio-CD can't be played with PC stpadberg Linux - Desktop 2 09-01-2006 06:39 PM
Recording Audio-in Dirk the Daring Linux - General 0 12-23-2004 11:43 AM
need help recording audio havokok Linux - Software 0 03-03-2004 08:41 PM
No audio when played from CD kesavan Linux - General 3 02-04-2004 05:20 PM


All times are GMT -5. The time now is 08:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration