[FFmpeg-devel] [PATCH] libavformat: add "capture:" protocol using AVIO

Moritz Barsnick barsnick at gmx.net
Wed Apr 12 01:43:31 EEST 2017

On Tue, Apr 11, 2017 at 14:12:08 +1000, Timothy Lee wrote:
> Capture is an input stream capture protocol that dumps the input stream to a
> file.  The default name of the output file is "capture.dat", but it can be
> changed using the "capture_file" option.


> +Input stream capturing protocol.

Probably worth pointing out more exactly what it does. Even I can only
guess: Dumps the raw payload, in *addition* to demuxing the input as

> +A capture URL has the form:
> + at example
> +capture:@var{URL}

That makes it an additional protocol prefix, right? So you can end up
having two (or more?). "capture:file:/path/bla"
(Confusing to me as a user at first sight, but ingenious if it works.
Yes, I did test it.)

> +For example, to capture the input stream as @file{stream.sav} during playback:
> + at example
> +ffplay -capture_file stream.sav capture:@var{URL}

So, is this the perfect replacement for "mplayer -dumpstream [-dumpfile
capture.dat]"? :-) Probably also worth noting somewhere.

If you go with Nicolas's suggestions, this comment is obsolete, but:

> +    c->fd = avpriv_open(c->capture_file, O_WRONLY|O_BINARY|O_TRUNC|O_CREAT, 0666);
> +    if (c->fd < 0)
> +        av_log(h, AV_LOG_ERROR, "Failed to create capture file\n");

If you're going to print a message, please also evaluate errno, for the
sake of the user.


More information about the ffmpeg-devel mailing list