[FFmpeg-devel] [PATCH] lavf: add ffprobe demuxer

Michael Niedermayer michael at niedermayer.cc
Wed Oct 26 02:46:35 EEST 2016


On Tue, Oct 25, 2016 at 05:07:34PM +0200, Stefano Sabatini wrote:
> On date Tuesday 2016-10-18 16:06:47 +0200, Michael Niedermayer encoded:
> > On Tue, Oct 18, 2016 at 01:33:27PM +0200, Stefano Sabatini wrote:
> > > On date Thursday 2016-10-13 19:46:41 +0200, Stefano Sabatini encoded:
> > > > On date Thursday 2016-09-29 21:55:11 +0200, wm4 encoded:
> > > [...]
> > > > > This seems like a rather special use case. Why does it have a demuxer,
> > > > > and can't be in your own C code using libavcodec/libavformat?
> > > > > 
> > > > 
> > > > > In addition, I think using the ffprobe "format" is an overcomplication,
> > > > > and will justify adding even more stuff to the demuxer, until it's a
> > > > > similarily complex mess like the ffm demuxer/muxer.
> > > > 
> > > > I'm aware of the issue. OTOH I think the feature per-se is useful, at
> > > > least for the two mentioned use cases (debugging - especially if
> > > > coupled with a corresponding muxer), and data streams (generated by
> > > > script) injection, since it relies on a textual format easily
> > > > scriptable and editable by hand.
> > > > 
> > > > I thus leave the choice to the community. I guess this will require a
> > > > vote if we cannot find an agreement.
> > > > 
> > > > Latest patch in attachment with ffprobe demuxer disabled by default,
> > > > and extended documentation. (I'm also attaching the ff_get_line2 patch
> > > > which is used by this new patch).
> > > 
> > > Updated, depends on the ff_get_line2() patch.
> > > -- 
> > > FFmpeg = Fanciful and Fundamentalist Magnificient Ponderous Elastic Game
> > 
> > >  configure                |    3 
> > >  doc/demuxers.texi        |   18 ++
> > >  doc/ffprobe-format.texi  |  121 ++++++++++++++
> > >  doc/formats.texi         |    1 
> > >  libavformat/Makefile     |    1 
> > >  libavformat/allformats.c |    1 
> > >  libavformat/ffprobedec.c |  405 +++++++++++++++++++++++++++++++++++++++++++++++
> > >  7 files changed, 550 insertions(+)
> > > 1d8a987564e907802dfd84722e3f5aafa69919ee  0002-lavf-add-ffprobe-demuxer.patch
> > > From bef4930a2bf280425b5952de0e2281f03897ff7c Mon Sep 17 00:00:00 2001
> > > From: Nicolas George <george at nsup.org>
> > > Date: Sat, 11 Jan 2014 19:42:41 +0100
> > > Subject: [PATCH] lavf: add ffprobe demuxer
> > > 
> > > With several modifications and documentation by Stefano Sabatini
> > > <stefasab at gmail.com>.
> > > 
> > > Signed-off-by: Nicolas George <george at nsup.org>
> > > ---
> > [...]
> > > +static int read_section_packet(AVFormatContext *avf, AVPacket *pkt)
> > > +{
> > > +    FFprobeContext *ffp = avf->priv_data;
> > > +    uint8_t buf[4096];
> > > +    int ret;
> > > +    AVPacket p;
> > > +    char flags;
> > > +
> > > +    av_init_packet(&p);
> > > +    p.pos = avio_tell(avf->pb);
> > > +    p.stream_index = -1;
> > > +    p.size = -1;
> > > +    av_bprint_clear(&ffp->data);
> > > +    while ((ret = read_section_line(avf, buf, sizeof(buf)))) {
> > > +        int has_time = 0;
> > > +        int64_t pts, dts, duration;
> > > +        char timebuf[1024];
> > > +
> > > +        if (ret < 0)
> > > +            return ret;
> > > +        if (sscanf(buf, "stream_index=%d", &p.stream_index)) {
> > > +            if ((unsigned)p.stream_index >= avf->nb_streams) {
> > > +                av_log(avf, AV_LOG_ERROR, "Invalid stream number %d specified in packet number %d\n",
> > > +                       p.stream_index, ffp->packet_nb);
> > > +                return AVERROR_INVALIDDATA;
> > > +            }
> > > +        }
> > > +
> > > +#define PARSE_TIME(name_, is_duration)                                  \
> > > +        sscanf(buf, #name_ "=%"SCNi64, &p.name_);                       \
> > 
> > > +        has_time = sscanf(buf, #name_ "_time=%s", timebuf);             \
> > 
> 
> > %s may be unsafe, not sure if theres a check elsewhere that prevents
> > writing over the outut buffer
> 
> Now the buffer is big enough, since it has the same size of the read
> line.
> -- 
> FFmpeg = Fanciful and Formidable Maxi Patchable Ecletic Geisha

>  configure                |    3 
>  doc/demuxers.texi        |   18 ++
>  doc/ffprobe-format.texi  |  121 ++++++++++++++
>  doc/formats.texi         |    1 
>  libavformat/Makefile     |    1 
>  libavformat/allformats.c |    1 
>  libavformat/ffprobedec.c |  405 +++++++++++++++++++++++++++++++++++++++++++++++
>  7 files changed, 550 insertions(+)
> 267580c51d49daf94e73a33175c63ecfed6a0bed  0002-lavf-add-ffprobe-demuxer.patch
> From 4e0aac4bc00104483859f9950af2ffb15fea6c12 Mon Sep 17 00:00:00 2001
> From: Nicolas George <george at nsup.org>
> Date: Sat, 11 Jan 2014 19:42:41 +0100
> Subject: [PATCH] lavf: add ffprobe demuxer
> 
> With several modifications and documentation by Stefano Sabatini
> <stefasab at gmail.com>.
> 
> Signed-off-by: Nicolas George <george at nsup.org>
> ---
>  configure                |   3 +
>  doc/demuxers.texi        |  18 +++
>  doc/ffprobe-format.texi  | 121 ++++++++++++++
>  doc/formats.texi         |   1 +
>  libavformat/Makefile     |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/ffprobedec.c | 405 +++++++++++++++++++++++++++++++++++++++++++++++
>  7 files changed, 550 insertions(+)
>  create mode 100644 doc/ffprobe-format.texi
>  create mode 100644 libavformat/ffprobedec.c

did you test this with some fuzzer ?

no further comments from me
Acked-by: Michael

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161026/627e8b98/attachment.sig>


More information about the ffmpeg-devel mailing list