[Libav-user] Reading large video file from named pipe

Abel Daniel abeld at hal.elte.hu
Mon May 9 13:44:39 CEST 2011


Hi!

I am trying to process a video stream encoded with
http://www.hauppauge.com/site/products/data_hdpvr.html (which encodes
into a mpeg ts stream, with the video encoded with h264) by opening it
with libavformat / libavcodec and doing some computer vision stuff
with opencv functions. The video stream is stored in 2Gb files,
(ie. the stream coming from the hdpvr is cut up to avoid having a
single huge file). I would like to be able to process the video stream
without having to switch between these files, if possible. Since these
files come from a single stream, and cat-ing them together gives the
data in that stream, I assumed that I can simply create a named pipe,
open that from my program and feed that named pipe by cat-ing the
files (in the right order) into it.

However, when I try to do this, I can't seem to read the video
properly: after a bunch of frames are read, the program crashes with a
segfault.

Running the program under strace both when reading from a file and
when reading from a named pipe, I noticed that libavformat/libavcodec
would want to do a bunch of seeks to different parts of the input,
which, of course, fails when reading from a pipe.

However, considering that ffmeg can process data coming from pipes
(based on http://ffmpeg.org/ffmpeg-doc.html#SEC41 and
http://ffmpeg.org/faq.html#TOC27) and since the container format (mpeg
ts) is stream-oriented and thus shouldn't require having the full
video (from beginning to end) available for it to be decoded, I assume
that there is some way to read multiple files as if they were one
large file, in a streaming fashion.

Is there a switch somewhere I am missing? Is this sort of usage
possible at all?

Thanks in advance,
Daniel Abel
abeld at hal.elte.hu

ps. If all else fails, I guess I can try to make something resembling
a 'seekable named pipe' using a user-space file system, somewhat like
http://chunkfs.florz.de/ but that would be a much more complicated
solution, if there is a simple 'assume input is a stream and don't try
to seek' switch somewhere.


More information about the Libav-user mailing list