Piping raw data info ffmpeg

FFMPEG is a great swiss-army tool for video manipulation. I recently had need to use ffmpeg and ffserver to pass a video feed – constructed of static images – to a remote server, for wider redistribution. Searching google, the top hit for “piping rgb data to ffmpeg” results in this article from Kyle Cordes, which is several years old. In the article, Kyle details his efforts in piping raw data into ffmpeg, and the requisite conversion from RGB to theĀ yuv4mpegpipe format.

There has apparently been quite some progress on ffmpeg since that article, as now piping data into ffmpeg is relatively easy. Firstly, create your pipe:

$ mkfifo image_pipe

Then, using your own code, write the data to the pipe in RGB tuples:

...
fifo f();
f.open( "image_pipe");
std::vector<image>::iterator it = images.begin();
while( it != images.end() )
    f.write( it->m_data, it->height, it->width );
...

Then, invoke ffmpeg with the command:

$ ffmpeg -f rawvideo -pix_fmt rgb24 -s 512x384 -y -an -i \
 ./image_pipe http://localhost:8090/image_feed.ffm

which will stream the images direct to your server for redistribution.

This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Piping raw data info ffmpeg

  1. Kyle Cordes says:

    I hope my (somewhat obsolete?) post was helpful, and I’m thrilled to read that it’s not as painful now as it was back then.

  2. ian says:

    Hi Kyle – your post was incredibly helpful, thanks for your work. I tried to comment on the page, but I think that it was locked…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>