[FFmpeg-devel] [PATCH] ffprobe integration
Michael Niedermayer
michaelni
Mon Feb 15 02:22:09 CET 2010
On Mon, Feb 15, 2010 at 12:59:13AM +0100, Stefano Sabatini wrote:
> On date Sunday 2010-02-14 23:31:11 +0100, Michael Niedermayer encoded:
> > On Sun, Feb 14, 2010 at 07:19:16PM +0100, Stefano Sabatini wrote:
> [...]
> > > Dropped opt.c use, flags and enum for units.
> >
> > great now its 339 lines instead of 416
> >
> >
> > [...]
> >
> > > +#define UNIT_NONE_STR ""
> > > +#define UNIT_SECOND_STR "s"
> > > +#define UNIT_HERTZ_STR "Hz"
> > > +#define UNIT_BIT_STR "bit"
> > > +#define UNIT_BYTE_STR "byte"
> > > +#define UNIT_BIT_PER_SECOND_STR "bit/s"
> > > +#define UNIT_BYTE_PER_SECOND_STR "byte/s"
> >
> > static const char *unit_none_str=""
> > ...
> > would allow you to compare for == and avoid the strcmp
>
> Fine.
>
> > [...]
> > > +static char *time_value_string(char *buf, int buf_size, int64_t val, AVRational *time_base)
> > > +{
> >
> > > + if (val == AV_NOPTS_VALUE)
> > > + snprintf(buf, buf_size, "N/A");
> > > + else
> >
> > {}
>
> Done.
>
> > [...]
> >
> > > + /* output avi tags */
> > > + a = isprint(a = dec_ctx->codec_tag & 0xff) ? a : '_';
> > > + b = isprint(b = dec_ctx->codec_tag>>8 & 0xff) ? b : '_';
> > > + c = isprint(c = dec_ctx->codec_tag>>16 & 0xff) ? c : '_';
> > > + d = isprint(d = dec_ctx->codec_tag>>24 & 0xff) ? d : '_';
> >
> > obfuscated
>
> Deobfuscated.
> Also I changed how it prints the unprintable characters, it should
> help to make more intelligible some fourcc, e.g.:
> RGB_ -> RGB[15]
>
> > > + printf("codec_tag_string=%c%c%c%c\n", a, b, c, d);
> > > + printf("codec_tag=0x%04x\n", dec_ctx->codec_tag);
> > > +
> > > + switch (dec_ctx->codec_type) {
> > > + case CODEC_TYPE_VIDEO:
> > > + printf("width=%d\n", dec_ctx->width);
> > > + printf("height=%d\n", dec_ctx->height);
> > > + printf("has_b_frames=%d\n", dec_ctx->has_b_frames);
> > > + printf("sample_aspect_ratio=%d:%d\n", dec_ctx->sample_aspect_ratio.num,
> > > + dec_ctx->sample_aspect_ratio.den);
> > > + printf("display_aspect_ratio=%d:%d\n", dec_ctx->sample_aspect_ratio.num,
> > > + dec_ctx->sample_aspect_ratio.den);
> > > + printf("pix_fmt=%s\n", av_pix_fmt_descriptors[dec_ctx->pix_fmt].name);
> > > + break;
> > > +
> > > + case CODEC_TYPE_AUDIO:
> > > + printf("sample_rate=%s\n", value_string(val_str, sizeof(val_str),
> > > + (double)dec_ctx->sample_rate,
> >
> > useless cast
> >
> >
> > > + UNIT_HERTZ_STR));
> > > + printf("channels=%d\n", dec_ctx->channels);
> > > + printf("bits_per_sample=%d\n", av_get_bits_per_sample(dec_ctx->codec_id));
> > > + break;
> > > +
> >
> > > + default:
> > > + break;
> >
> > useless
>
> Removed.
>
> Regards.
> --
> FFmpeg = Freak & Fostering Mega Problematic Ecumenical Ghost
> Makefile | 5
> configure | 4
> doc/ffprobe-doc.texi | 90 +++++++++++++
> ffprobe.c | 337 +++++++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 434 insertions(+), 2 deletions(-)
> f24c4ebc26d189005832fa33045321246b79168f add-ffprobe.patch
> Index: ffmpeg/Makefile
> ===================================================================
> --- ffmpeg.orig/Makefile 2010-02-14 14:29:34.000000000 +0100
> +++ ffmpeg/Makefile 2010-02-14 17:41:54.000000000 +0100
> @@ -6,6 +6,7 @@
>
> PROGS-$(CONFIG_FFMPEG) += ffmpeg
> PROGS-$(CONFIG_FFPLAY) += ffplay
> +PROGS-$(CONFIG_FFPROBE) += ffprobe
> PROGS-$(CONFIG_FFSERVER) += ffserver
>
> PROGS := $(addsuffix $(EXESUF), $(PROGS-yes))
> @@ -15,7 +16,7 @@
> TOOLS = $(addprefix tools/, $(addsuffix $(EXESUF), cws2fws pktdumper probetest qt-faststart trasher))
> HOSTPROGS = $(addprefix tests/, audiogen videogen rotozoom tiny_psnr)
>
> -BASENAMES = ffmpeg ffplay ffserver
> +BASENAMES = ffmpeg ffplay ffprobe ffserver
> ALLPROGS = $(addsuffix $(EXESUF), $(BASENAMES))
> ALLPROGS_G = $(addsuffix _g$(EXESUF), $(BASENAMES))
> ALLMANPAGES = $(addsuffix .1, $(BASENAMES))
> @@ -87,7 +88,7 @@
> alltools: $(TOOLS)
>
> documentation: $(addprefix doc/, developer.html faq.html ffmpeg-doc.html \
> - ffplay-doc.html ffserver-doc.html \
> + ffplay-doc.html ffprobe-doc.html ffserver-doc.html \
> general.html libavfilter.html $(ALLMANPAGES))
>
> doc/%.html: doc/%.texi
> Index: ffmpeg/configure
> ===================================================================
> --- ffmpeg.orig/configure 2010-02-14 14:29:34.000000000 +0100
> +++ ffmpeg/configure 2010-02-14 17:41:54.000000000 +0100
> @@ -82,6 +82,7 @@
> --disable-doc do not build documentation
> --disable-ffmpeg disable ffmpeg build
> --disable-ffplay disable ffplay build
> + --disable-ffprobe disable ffprobe build
> --disable-ffserver disable ffserver build
> --disable-avdevice disable libavdevice build
> --disable-avcodec disable libavcodec build
> @@ -890,6 +891,7 @@
> fastdiv
> ffmpeg
> ffplay
> + ffprobe
> ffserver
> fft
> golomb
> @@ -1395,6 +1397,7 @@
> ffmpeg_deps="avcodec avformat swscale"
> ffplay_deps="avcodec avformat swscale sdl"
> ffplay_select="rdft"
> +ffprobe_deps="avcodec avformat"
> ffserver_deps="avformat ffm_muxer rtp_protocol rtsp_demuxer"
> ffserver_extralibs='$ldl'
>
> @@ -1446,6 +1449,7 @@
> enable fastdiv
> enable ffmpeg
> enable ffplay
> +enable ffprobe
> enable ffserver
> enable mpegaudio_hp
> enable network
> Index: ffmpeg/ffprobe.c
> ===================================================================
> --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> +++ ffmpeg/ffprobe.c 2010-02-15 00:57:42.000000000 +0100
> @@ -0,0 +1,337 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#undef HAVE_AV_CONFIG_H
> +#include "libavformat/avformat.h"
> +#include "libavcodec/avcodec.h"
> +#include "libavcodec/opt.h"
> +#include "libavutil/pixdesc.h"
> +#include "cmdutils.h"
> +
> +const char program_name[] = "FFprobe";
> +const int program_birth_year = 2007;
> +
> +static int do_show_format = 0;
> +static int do_show_streams = 0;
> +
> +static int show_value_unit = 0;
> +static int show_value_prefix = 0;
> +static int use_byte_value_binary_prefix = 0;
> +static int use_value_sexagesimal_format = 0;
> +
> +/* globals */
> +static const OptionDef options[];
> +
> +/* FFprobe context */
> +static const char *input_filename;
> +
> +static const char *binary_unit_prefixes[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" };
> +static const int binary_unit_prefixes_nb = FF_ARRAY_ELEMS(binary_unit_prefixes);
please use FF_ARRAY_ELEMS() directly
[...]
> +static char *time_value_string(char *buf, int buf_size, int64_t val, AVRational *time_base)
time_base should be const if you pass it as pointer
[...]
> + printf("size=%s\n", value_string(val_str, sizeof(val_str), (double)fmt_ctx->file_size,
> + unit_byte_str));
useless cast
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100215/cac78626/attachment.pgp>
More information about the ffmpeg-devel
mailing list