[LAD] audio recording through pipe using mplayer and sox sometimes has incorrect speed

From: Arnold Obdeijn <arnold.obdeijn@email-addr-hidden>
Date: Thu Apr 09 2009 - 15:24:27 EEST

Hi all,

I am using mplayer, sox and tee to capture streaming internet radio
and send it both to an audio recognition program and to a file
(recording).
This is how I do it:

mplayer -playlist {url} -nocache -af volnorm -msglevel all=1 -nolirc
-vc dummy -vo null -ao pcm:file={$fifo1} &

sox -S {$fifo1} -c 1 -r 8000 -t wav - resample | tee {$recording} |
tee {$fifo2} & ......

$fifo1 and $fifo2 are named pipes, $fifo2 is processed by an audio
recognition program. The idea is that the audio is converted to low
quality wav (8000Hz mono) after which it is fed to the program and
simultaneously recorded.

This works great most of the time but sometimes the recording is too
long/slow or too short/fast. Sometimes the speed is slighly wrong and
sometimes it is terribly wrong. When the speed is too slow, I notice
that the file is also much larger and if I open the file in Audacity,
the program tells me that the duration of the recording is for example
two hours in stead of 1 hour (when the speed is twice as slow as it
should be). Below is a list of three recordings that are the product
of this setup. The middle one is larger and when I play it back it is
three times too slow.

55M 2009-04-09 07:00 /data/station_recordings/48_20090409-0600.wav
152M 2009-04-09 06:00 /data/station_recordings/48_20090409-0500.wav
55M 2009-04-09 05:00 /data/station_recordings/48_20090409-0400.wav

My guess is that it has something to do with the sample rate. If
anyone has any idea where this goes wrong or what I could do to try to
fix it, please let me know.

Arnold.
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Thu Apr 9 16:15:02 2009

This archive was generated by hypermail 2.1.8 : Thu Apr 09 2009 - 16:15:02 EEST