LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-25-2007, 03:12 PM   #1
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Rep: Reputation: 30
real time mp3 recording


Hello,
I use to record long time radio transmission (up to six hours) with
audacity and then export to mp3. However, this is not a practical
solution. I am looking for tools (even command line, I found a sox | lame
pipe) that could do this for me directly while recording. My pc is a
celeron 600 Mhz with 320 RAM, is it enough powerful to do this in
real-time?
(I hope the best mp3 quality - constant rate at 320 Kps).
Thanks,
Gaetano
 
Old 10-25-2007, 04:05 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Try it and see. I'd use the ALSA tool arecord to grab the data from the sound card and pipe that directly into lame, like this:
Code:
arecord -f cd |lame -b 320 recording.mp3
The -f cd part says to use CD quality (44.1 kHz, 16 bit stereo). Read the arecord manual page and select something else if you prefer. The -b 320 option to lame says "constant bitrate" at the rate you specified.

What I'd do is run top or some similar tool in one terminal, and your encoder in another, and over time see what the CPU load is - this will probably be a CPU-bound task. Lame takes about 25% of my CPU on my 1.7 GHz system... I think it'll be close to 100% for you, but maybe your system is fast enough. Just make sure you don't have heave tasks scheduled with cron to operate half way through your recording!

If you're going to be needing very long recordings, it might be prudent to put the command in a loop which will make it automatically re-start if there is a problem. Maybe like this:
Code:
n=0; while true; do let n+=1; arecord -f cd |lame -b 320 - recording$n.mp3; done
 
Old 10-25-2007, 04:40 PM   #3
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 65
The one I know of is called mp3record. it too is a script that uses sox and lame.

Brian
 
Old 10-26-2007, 08:53 AM   #4
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Original Poster
Rep: Reputation: 30
Thanks! Now I will try
 
Old 10-28-2007, 03:47 PM   #5
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Original Poster
Rep: Reputation: 30
Mmmhh, I have tried with the arecord | lame pipe and
stops the recordings after about three hours, giving
me a whistle sound for some minutes and then returning
to the terminal. I think that arecord, like sox, is
limited by the standard C library to sample at best
2 GB.. What could I do? I think to write a simple
read/write loop with ALSA by myself..
 
Old 10-28-2007, 04:35 PM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Ouch! I agree that this is likely caused by the 2GiB limit.

The solution which I would try first is to re-build arecord and lame to use 64 bit file pointers. GNU libc compiles with 32 bit file pointers on 32 bit systems unless explicitly told to use 64 bit file pointers. I guess this is a performance thing.

To tell GNU libc that you want to use 64 bit file pointers is easy - just define the symbol _FILE_OFFSET_BITS as 64 at compile time.

In the case of the ALSA utilities package which contains arecord, you can do this by passing an option when you do the configure stage of the build process, like this:
Code:
./configure CFLAGS=-D_FILE_OFFSET_BITS=64
I am using kubuntu, so fetching the source was just a matter of using the command:
Code:
apt-get source alsa-utils
The build process actually failed (very unusual for a package retrieved in this way), but it build enough to have an arecord binary which works. You can test to see if it is using 64 bit file pointers like this (from the directory where the new arecord is made):
Code:
strace ./arecord -d 1 output.wav 2>&1 | grep open |grep output.wav
You should see something like this:
Code:
open("output.wav", O_WRONLY|O_CREAT|O_LARGEFILE, 0644) = 5
If the O_LARGEFILE is absent, you are still using 32 bit file pointers.

I didn't try the same thing with lame, but I imagine you can use a similar process.

Good luck!
 
Old 10-29-2007, 03:02 PM   #7
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 44
This records from line in

sox -t ossdsp -w -s -r 44100 -c 2 /dev/dsp -t raw - | lame -x -m s - ./filename.mp3


This records from an internet stream

mplayer -dumpstream -dumpfile ./filename.mp3 mms://location.to.stream


substitute your stream you want to record for the mms link
 
Old 10-30-2007, 04:48 AM   #8
tanoatlq
Member
 
Registered: Mar 2007
Posts: 157

Original Poster
Rep: Reputation: 30
Running strace on the current executables (I did not recompile them),
give me:

for arecord:

open("test.wav", O_WRONLY|O_CREAT|O_LARGEFILE, 0644) = 6

for lame:

open("/etc/ld.so.cache", O_RDONLY) = 3
open("/lib/libncurses.so.5", O_RDONLY) = 3
open("/lib/tls/libm.so.6", O_RDONLY) = 3
open("/lib/tls/libc.so.6", O_RDONLY) = 3
open("/lib/tls/libdl.so.2", O_RDONLY) = 3
open("1", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)

So these binaries are already compiled with support for large files?
?!?!?!
 
Old 10-30-2007, 05:15 AM   #9
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Looks like it. It appears I am missing something in my understanding.
 
  


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
Real Time Clock & Real Time Timer jiramak Linux - Newbie 1 09-05-2007 06:43 PM
LXer: Real-time garbage collection with Real-time Java LXer Syndicated Linux News 0 05-05-2007 12:16 PM
LXer: Real-time Linux gains real-time JVM LXer Syndicated Linux News 0 10-12-2006 10:54 AM
LXer: Real Time Coming to Linux Real Soon LXer Syndicated Linux News 1 08-23-2006 06:30 PM
Sound recording with real-time effects qscomputing Linux - Software 1 05-23-2006 11:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:52 PM.

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