LinuxQuestions.org
Visit Jeremy's Blog.
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 12-11-2008, 10:39 PM   #1
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 449

Rep: Reputation: 34
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:
Code:
$ 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
 
Old 12-12-2008, 05:01 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
A few things of note here.

1) Your mkfifo appears to have failed. That 'ls -lh /tmp/audio' output should have a 'p' as the first character to denote a pipe, e.g. prw-r--r--. You've been cat'ing a normal file (arecord's probably clobbered the fifo and replaced it with a file).

2) I think you may be misunderstanding what a FIFO is. The 'buffer' is only 4kB long on i386 Linux, and that buffer is just a kernel memory area that makes read-writes more efficient. There's no real buffering going on - named pipes are just a convenient way of doing inter-process communication. No data ever hits the disks.

3) As soon as either end of a pipe is closed, the IPC is torn down for everything in the pipe. There's no way to 'reconnect' to a pipe once it's closed.

Dave

Last edited by ilikejam; 12-12-2008 at 05:48 AM. Reason: typo
 
Old 12-12-2008, 06:25 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Think I might have a better idea, though.

Install the 'ogmtools' package, if you don't already have it.

$ mkfifo /tmp/pipe.ogg
$ ogmsplit <options> /tmp/pipe.ogg &
$ arecord <options> | oggenc <options> > /tmp/pipe.ogg

This will record and encode into the /tmp/pipe.ogg FIFO, and the resulting ogg stream will be split by 'ogmsplit' into seperate files.

Not tried it myself, but should hopefully do what's needed. Only problem might be if ogmsplit needs to rewind through the input file, to get a previous frame or something.

Dave

Last edited by ilikejam; 12-12-2008 at 06:28 AM.
 
Old 05-03-2018, 08:06 PM   #4
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 449

Original Poster
Rep: Reputation: 34
Closing the loop on this extremely old problem... I finally found a turnkey solution in LiquidSoap (http://savonet.sourceforge.net/). There is also rotter (https://www.aelius.com/njh/rotter/)
 
  


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
Regarding behaviour of FIFO Sathya Programming 2 05-23-2008 10:32 AM
strange behaviour marsques Slackware 11 02-15-2006 06:05 PM
Strange Behaviour! joshuarowley LQ Suggestions & Feedback 1 12-08-2005 03:36 PM
Strange behaviour Anmol SUSE / openSUSE 2 10-27-2005 11:05 PM
Strange Behaviour mikeyt_3333 Linux - General 4 08-06-2001 03:07 PM

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

All times are GMT -5. The time now is 04:01 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