Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Long story short; I'm running this command to stream a forever growing audio file audio.mpg into ffmpeg

tail -F audio.mp3 | ffmpeg -i -

audio.mp3 is being SSH'd from another server which has a capture device feeding the data through. This is working correctly, however audio.mp3 is constantly growing, and all I really need is to send the tail mp3 data to ffmpeg in order encode and send it to ffserver on the same machine.

Is there a command I can run to output tail -F and also remove the outputted data from audio.mp3.

In essence, I want to put a 1MB limit on the file size of audio.mp3

Thanks in advance

share|improve this question
up vote 1 down vote accepted

It sounds like a "named pipe" problem (Sherlock Holmes, please forgive me). Since the data is not supposed to remain on your system, you should create a named pipe,

 mkfifo my_pipe

and then have the SSH process write to it, and you can read from it:

cat < my_pipe | ffmpeg -i -

When the process that writes data has completed, an EOF will appear in cat, and you will be free to stop the cat-ing by means of Ctrl+C. Of course you can also be smarter, writing a small script that waits on an EOF; as long as it does not find it, it passes the data along, when it does find the EOF, it shuts down the operation. This way you do not have to monitor the whole process.

share|improve this answer
(1) Rather than cat < my_pipe | ffmpeg -i -, you could say ffmpeg -i - < my_pipe or < my_pipe ffmpeg -i - (2) When the process that writes data has completed, an EOF will appear in the pipe, and ffmpeg should terminate, just as it would if it were reading from an ordinary file. You shouldn’t need Ctrl+C. – Scott Oct 16 '13 at 0:25
good point, ty. – MariusMatutiae Oct 16 '13 at 4:23
Thanks Marius, I never knew FIFO's existed, but upon searching about them, I can see how handy they can be! – Moe Oct 16 '13 at 12:19
They are used for inter-process communication, of which this is but a simple example. There are spiffier ones. – MariusMatutiae Oct 16 '13 at 12:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.