LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-20-2010, 02:57 PM   #16
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57

Quote:
video:0kB audio:1479kB global headers:0kB muxing overhead 0.002905%
The last line in the output where the audio is 1479kB means it has recorded the file successfully. Did you install the codecs to play media files?

It should have played. I use this method to record audio streams where downloading or playing from cache is not possible.

A few simple notes and questions:

Note: Allow time for the playing audio to be recorded. There will be a few seconds or more of silence in the beginning until the recording terminal receives an output from the speaker/soundcard. This depends how quickly the audio on the site start playing.


Have you checked the audio levels? I always keep mine at 95%. If you use 100%, this can cause clipping or distortion -- sometimes not.

Are you playing the audio as you are recording? If not, you need to do both. As firefox is playing the audio via flash or whatever, a terminal is open recording the output of your speakers/soundcard.

Do you have more than one application openrd that uses the soundcard? If yes, close all except for firefox.

Do you have more than one sound card? if yes, you need to adjust the sound device node

For OSS
/dev/dsp /dev/dsp1 /dev/dsp3 ...

Alsa

hw:0 hw:1 hw:3 ...

Try this code

Code:
ffmpeg -f alsa -i hw:0  out.wav
It works fine on my system.

let's hope it will work on your side.

Let us know...

Last edited by dv502; 04-20-2010 at 04:19 PM.
 
Old 04-20-2010, 04:16 PM   #17
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
ffmpeg's syntax can be a bit quirky. You have options that come BEFORE -i and AFTER -i and even AFTER -?codec and each gets applied in different ways, or just ignored if they don't make sense. You really have to know what you're doing and even then you might not get what you're looking for. ffmpeg can be quite quirky when recording realtime input. ffmpeg is great as a video decoder and transcoder for existing content. Not so much for capture in realtime from hardware. At least that's my experience.

so:

$ ffmpeg -f oss -ac 2 -ar 44100 -i /dev/dsp -ac 2 -ar 44100 -acodec vorbis -ab 192k -aq 100 -y out.ogg
(to be overly redundant in the style of ffmpeg)

I've never had much joy using ffmpeg to record audio directly. It's a little too prone to speed up and slow down as needed (system resources), or skip chunks of audio in combination with video to maintain sync, or just to have a mind of it's own in general. I was testing with "$ echo "this is a test" | festival --tts" as the input sound maker and results were inconsistent with ffmpeg. Even though the input is literally programmatically consistent. You're better off using a lighter engine like arecord IMO.

$ aumix -v 35 -m 35 -i 35 -v R
$ arecord -f cd test.wav

in another console / xterm

$ for PAUSE in 0 1 2 3 4 5; do sleep $PAUSE; echo "this is a test." | festival --tts; done

kick off recording, then kick off that noise maker. Compare results via ffmpeg and via arecord for basically the same source and it might sway your vote too.
 
Old 04-20-2010, 08:00 PM   #18
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
ffmpeg -f oss -i /dev/dsp out.wav
ffmpeg -f alsa -i hw:0 out.wav

I've use these codes and they work fine. There are no drop outs or noise in my audio files.

@ sumeet inani

If you still have problems using ffmpeg and arecord then use audacity as before.

You said earlier in your post after a hour of research and testing, you got it to work the way you wanted.

The codes that Shadow_7 and I provided do work, we don't know why it is not working on your side.

Last edited by dv502; 04-20-2010 at 08:29 PM.
 
Old 04-21-2010, 12:04 AM   #19
sumeet inani
Member
 
Registered: Oct 2008
Posts: 908

Original Poster
Blog Entries: 26

Rep: Reputation: 49
Arecord & audacity work fine.

ffmpeg -f alsa -i hw:0 out.wav
tells unknown input or output format

ffmpeg -f oss -ac 2 -ar 44100 -i /dev/dsp -ac 2 -ar 44100 -acodec vorbis -ab 192k -aq 100 -y out.ogg
Just like
ffmpeg -f oss -i /dev/dsp out.wav
seems to Work but give blank sound file.

On opening the wav file recorded via ffmpeg , I see its amplitude constantly hovers around 0.5
while in ogg it is two tracks both hanging around -0.5 while my original song is band between 0 and 0.5

when My volume control device is oss mixer I can tune three items:volume,pcm-2,in-gain
I keep all three near 90%.
dv502,Can you tell me what are values in your case ?
Also i saw this page http://alsa.opensrc.org/index.php/Ma..._to_alsa_mixer which makes me think that maybe capture source has to be defined ?
here is my /proc/asound/card0/oss_mixer.
Code:
VOLUME "Master" 0
BASS "" 0
TREBLE "" 0
SYNTH "" 0
PCM "" 0
SPEAKER "" 0
LINE "" 0
MIC "" 0
CD "" 0
IMIX "" 0
ALTPCM "Headphone" 0
RECLEV "" 0
IGAIN "Capture" 0
OGAIN "" 0
LINE1 "" 0
LINE2 "" 0
LINE3 "" 0
DIGITAL1 "" 0
DIGITAL2 "" 0
DIGITAL3 "" 0
PHONEIN "" 0
PHONEOUT "" 0
VIDEO "" 0
RADIO "" 0
MONITOR "" 0
What is different in yours ?

Last edited by sumeet inani; 04-21-2010 at 01:20 AM.
 
Old 04-21-2010, 01:02 AM   #20
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
@ sumeet inani

My /proc/asound/card0/oss_mixer is identical to yours above.

I am using kmix, a KDE mixer program. I use this to adjust the levels. My kmix levels are:

Vol is 99
PCM is 97
Line is 97

I did not include the other channels as they have no relevance during the recording. My soundcard is simple. It's a SoundBlaster 16. It has four ports Line-out, line-in, mic and joystick.

Have you tried using the Capture boost? The Capture level on my mixer is at zero. Maybe you can adjust the capture level to 50%-100% and do another test recording.

Another thing you can try is enabling the Mix channel as the recording source. It's found in the switches tab on kmix. The Mix channel will record any audio playing from the speaker. If you can hear it, it will record it.

Also, if you have multiple sound devices, there will be a drop-down box at the right. Be sure to select the recording device you wish to use.

Anyway, I hope these suggestions could improve the sound of your audio file.

BTW, if the audio is still low. Have you try using the normalize effect in audacity. This will amplify the volume as much as possible without causing clipping and/or distortion.

If you have the command utility, open a terminal and type

normalize file.wav


There is also normalize-mp3 and normalize-ogg

Last edited by dv502; 04-21-2010 at 01:34 AM.
 
Old 04-21-2010, 02:00 AM   #21
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
@ sumeet inani


OSS Recording

OSS has its own mixer program. In KDE it is called kmix and in GNOME, GNOME Volume Control.

Open kmix or GNOME Volume Control and adjust the levels for Vol and PCM to 95%

Open a video, audio file or website and play something with sound. Then open a terminal and type

ffmpeg -f oss -i /dev/dsp out.wav

Just type this. Don't add any other options. If it works, you can add the other options as you wish.

let me know if it work.

Last edited by dv502; 04-21-2010 at 02:35 AM.
 
Old 04-21-2010, 03:11 AM   #22
sumeet inani
Member
 
Registered: Oct 2008
Posts: 908

Original Poster
Blog Entries: 26

Rep: Reputation: 49
Finally it worked
First I set via alsamixer the settings which I have mentioned before then in volume control changed sound device to ossmixer.
Played a song recorded it via
ffmpeg -f oss -i /dev/dsp out.wav
It worked.
I think there are very few options in ossmixer (namely 3) so settings via alsamixer should be right because direct relation between both settings.
You have helped a lot ,dv502.Your suggestion about normalize effect in audacity was powerful.Also i have installed normalize-audio.
Now I know recording via audacity,ffmpeg & arecord.

it is rightly said linux users are spoilt for choice.

Last edited by sumeet inani; 04-21-2010 at 03:46 AM.
 
Old 04-21-2010, 03:32 AM   #23
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
Great!!!!

I had a gut feeling it was a matter of selecting the right mixer/device to do the recording.

I am just as happy as you are. And don't forget Shadow_7 with his arecord suggestion.

Great job sumeet inani

Last edited by dv502; 04-21-2010 at 07:02 AM.
 
Old 04-21-2010, 07:18 AM   #24
dv502
Member
 
Registered: Sep 2006
Location: USA - NYC
Distribution: Whatever icon you see!
Posts: 642

Rep: Reputation: 57
Now you can add those extra options to ffmpeg to produce the type of file you want.

ffmpeg -f oss -i /dev/dsp -acodec libmp3lame -ar 44100 -ab 128k -ac 2 out.mp3

This will produce a mp3 file at 16bit stereo, 44100 Hz at a bitrate of 128k. The out.mp3 can be any name you want, it's only an example.

I prefer recording to wav first as this produces the best quality and puts less strain on the CPU as it is recording and encoding at the same time. If your CPU is fast enough it will be no problem. After recording, you can use ffmpeg, mencoder or audacity to convert the wav file.

- Cheers

Last edited by dv502; 04-21-2010 at 10:12 AM.
 
Old 04-23-2010, 11:41 AM   #25
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
arecord vs. ffmpeg

Audacity has a number of editing features to taylor your final wav to tastes.

Normalize or Amplify

Hardlimit (any enthusiastic drummer / door slam / other thing that was loud and would limit the average loudness of everything else can be squashed down / tamed.)

Multiband EQ (sometimes there wasn't enough bass, or some annoying sound in a particular range that you can adjust to more tollerable levels.)

Select the portion of audio you want to edit in Audacity then:

Effects -> Amplify
Effects -> Normalize
Effects -> 151 to 165 -> Hard Limit
Effects -> 181 to 195 -> Multiband EQ

i.e. everything doesn't have to be perfect at the point of capture to get a good result. There's also ways to do the same things with sox and other software. Unfortunately a lot of them are not included by default and might have weird licensing or regional legalities that prevent them from ever being included in a lot of distros.

One should also note that what you see as 0.5 in the audacity waveform is really -5dB. If you were to hardlimit to -5dB, it would fall about where that point is. Or amplify to -5dB (which might actually do the opposite).

-----

The quirky issue with ffmpeg and realtime capture from a script like this:

Code:
#!/bin/sh

ffmpeg -f oss -ac 2 -ar 44100 -i /dev/dsp -t 00:00:30.000 \
       -acodec pcm_s16le -ac 2 -ar 44100 -y ttt_ffmpeg.wav &

sleep 1

for PAUSE in 0 1 2 3 4 5; do sleep $PAUSE; echo "test test test" | 
festival --tts; done

sleep 20

# ----------

arecord -f cd -d 30 ttt_arecord.wav &

sleep 1

for PAUSE in 0 1 2 3 4 5; do sleep $PAUSE; echo "test test test" | 
festival --tts; done

sleep 1
As seen in audacity:
$ audacity ttt_arecord.wav
File->Import->Audio [ttt_ffmpeg.wav]

http://home.earthlink.net/~shadow_7/ttt_result.gif

Technically the only difference between the two results should be some latency of when the applications loads and launches. Which should be in the neighborhood of less than 1 second. But as you can see in that screen capture, the difference is a lot more extreme. In ffmpegs defense I guess, ffmpeg does peek my system resources on my 32 bit 2GHz laptop circa 2006. In combination with the script and festival and other stuff since I ran the test in X. arecord has a bit more elbow room. I should note that speaker output was consistent, despite the resulting outputs.

In short ffmpeg doesn't work for me at the point of capture. Not to imply that it doesn't work at all. Or doesn't have a fix in the most recent cvs/svn/git. But my version (early 2010 / svn-r21496) on my gear (2006 laptop), not quite a result that I'm happy with. You're better off with arecord or audacity or ardour IMO.
 
Old 04-26-2010, 07:00 PM   #26
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
20Hz-20kHz is a limit of the microphones that record sound. With exceptions, but on average it is what it is.
 
  


Reply



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 06:27 AM
Strange: Audio-CD can't be played with PC stpadberg Linux - Desktop 2 09-01-2006 05:39 PM
Recording Audio-in Dirk the Daring Linux - General 0 12-23-2004 10:43 AM
need help recording audio havokok Linux - Software 0 03-03-2004 07:41 PM
No audio when played from CD kesavan Linux - General 3 02-04-2004 04:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:13 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
Open Source Consulting | Domain Registration