[FFmpeg-user] Disable buffering completely when encoding mp3.

sebastian nielsen nielsen.sebastian at gmail.com
Fri Dec 30 20:40:11 CET 2011


How I do to disable buffering completely when encoding with the LAME
mp3 encoder?

I have a application which is streamed over a VNC session, that also uses sound.
The problem is that the sound lags behind like 30 seconds. Eg, if I do
something on the screen, I hear the corresponding sound 30 seconds
later.

I did this:

First I use a vsound hook to catch the application's sounds and pipe
them to STDOUT in SUN AU format. (the server host 10 different
instances of the same application so I need to catch the application
sound with vsound, I cannot just use the sound from the soundcard
since theres only one soundcard on server).

Then I pipe it to a FIFO file. Lets call it "fifo_tmp".

Then I do
ffmpeg -f au -i fifo_tmp -f mp3 pipe:1 | cat > fifo_new

fifo_new is a another FIFO file.

Then I use this perl script hosted at a web server to pipe everything
to the user via HTTP streaming:

#!/usr/bin/perl

use CGI ':standard';

local $| = 1;
print "Content-Type: audio/mpeg\n\n";

binmode STDOUT;
open(PIPE, "fifo_new");
binmode PIPE;
while (read(PIPE,$data,1000000)) {
print $data;
}
close(PIPE);


The argument 1000000 says how much data to read at max each iteration,
have tried many different values here ranging from 1 byte to 100000000
but with the exactly same result.


I guess ffmpeg buffers when mp3-encoding. How I do to disable that
buffering completely, pushing out data frames as soon they are done.


More information about the ffmpeg-user mailing list