You are not logged in.

#1 2008-12-12 04:38:30

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Strange FIFO Behaviour

OK, this is driving me nuts!

This is the 3rd thread in my series about trying to get gapless audio recording working from the command line...

I'm having troubles with my FIFO buffer...

The Concept: Use arecord to send the raw audio input to a fifo buffer, and encode that raw data using oggenc. In order to split the output files, oggenc restarts periodically with a new filename. While it is restarting, the FIFO buffer is filling with the audio to be encoded once oggenc is running again. Ergo, not a millisecond of audio is missed.

There are 2 Problems with this.
1) arecord starts before oggenc. Therefore when oggenc reads the fifo, it just takes what's there, encodes it and says done. It doesn't keep going and going like if you piped arecord directly to oggenc. If oggenc is started before arecord, then it seem to work fine, however this isn't an option since oggenc has to restart regularly to change filenames, and arecord can not be stopped (otherwise we'll miss audio)
2) The fifo doesn't get emptied when it's read from. Example:

$ mkfifo /tmp/audio
$ ls -lh /tmp/audio 
-rw-r--r-- 1 fukawi2 fukawi2 0 2008-12-12 15:08 /tmp/audio
$ arecord --format cd --file-type raw /tmp/audio &
$ cat /tmp/audio > /tmp/empty_the_damn_fifo
$ ls -lh /tmp/
-rw-r--r-- 1 fukawi2 fukawi2 30M 2008-12-12 15:08 /tmp/audio
-rw-r--r-- 1 fukawi2 fukawi2 29M 2008-12-12 15:09 /tmp/empty_the_damn_fifo

1) Create the fifo
2) Show that it's there and empty
3) Start arecord in the background
4) cat the fifo to a normal file. This should empty the fifo back to 0 bytes.
5) ls shows the nromal file we cat'ed to is 29M, and the fifo has not emptied and grown another 1M

Here's the current script:
http://pastebin.com/m73d83a50

Thanks for reading this far! smile

Last edited by fukawi2 (2008-12-12 04:46:57)

Offline

#2 2008-12-12 07:25:40

Arkane
Member
From: Switzerland
Registered: 2008-02-18
Posts: 263

Re: Strange FIFO Behaviour

Seems yout mkfifo failed and your /tmp/audio is a regular file. If it were a fifo you'd see something like "prw-r--r--" in its permissions field (also, fifos always have size 0).

Don't know how this can happen though. Maybe the file was alreay there?

Last edited by Arkane (2008-12-12 07:32:33)


What does not kill you will hurt a lot.

Offline

#3 2008-12-12 08:30:57

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Strange FIFO Behaviour

See what an extra set of eyes can do - thank you Arkane smile

Next question is... the fifo IS created properly, however arecord appears to insist on making it into a normal file :S

fukawi2 /tmp/testing  $ mkfifo audio
fukawi2 /tmp/testing  $ ls -lh
total 0
prw-r--r-- 1 fukawi2 fukawi2 0 2008-12-12 19:28 audio
fukawi2 /tmp/testing  $ arecord --format cd --file-type raw ./audio 
Recording raw data './audio' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
^CAborted by signal Interrupt...
fukawi2 /tmp/testing  $ ls -lh
total 88K
-rw-r--r-- 1 fukawi2 fukawi2 80K 2008-12-12 19:29 audio
fukawi2 /tmp/testing  $

Outputting arecord to stdout and then redirecting to the fifo seems to work though... I'll keep experimenting smile

Offline

Board footer

Powered by FluxBB