[FFmpeg-devel] [PATCH] ffprobe: add -show_version option
Stefano Sabatini
stefasab at gmail.com
Fri Jan 6 19:55:24 CET 2012
---
doc/ffprobe.xsd | 44 ++++++++++++++++++++++++++++++++++++++++++
ffprobe.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 99 insertions(+), 2 deletions(-)
diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
index 93da1d4..348961c 100644
--- a/doc/ffprobe.xsd
+++ b/doc/ffprobe.xsd
@@ -12,6 +12,7 @@
<xsd:element name="streams" type="ffprobe:streamsType" minOccurs="0" maxOccurs="1" />
<xsd:element name="format" type="ffprobe:formatType" minOccurs="0" maxOccurs="1" />
<xsd:element name="error" type="ffprobe:errorType" minOccurs="0" maxOccurs="1" />
+ <xsd:element name="version" type="ffprobe:versionType" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
@@ -99,4 +100,47 @@
<xsd:attribute name="code" type="xsd:int" use="required"/>
<xsd:attribute name="string" type="xsd:string" use="required"/>
</xsd:complexType>
+
+ <xsd:complexType name="versionType">
+ <xsd:attribute name="version" type="xsd:string" use="required"/>
+ <xsd:attribute name="copyright" type="xsd:string" use="required"/>
+ <xsd:attribute name="build_date" type="xsd:string" use="required"/>
+ <xsd:attribute name="build_time" type="xsd:string" use="required"/>
+ <xsd:attribute name="compiler_type" type="xsd:string" use="required"/>
+ <xsd:attribute name="compiler_version" type="xsd:string" use="required"/>
+ <xsd:attribute name="configuration" type="xsd:string" use="required"/>
+ <xsd:attribute name="libavutil_major" type="xsd:int"/>
+ <xsd:attribute name="libavutil_minor" type="xsd:int"/>
+ <xsd:attribute name="libavutil_micro" type="xsd:int"/>
+ <xsd:attribute name="libavutil_version" type="xsd:int"/>
+ <xsd:attribute name="libavcodec_major" type="xsd:int"/>
+ <xsd:attribute name="libavcodec_minor" type="xsd:int"/>
+ <xsd:attribute name="libavcodec_micro" type="xsd:int"/>
+ <xsd:attribute name="libavcodec_version" type="xsd:int"/>
+ <xsd:attribute name="libavformat_major" type="xsd:int"/>
+ <xsd:attribute name="libavformat_minor" type="xsd:int"/>
+ <xsd:attribute name="libavformat_micro" type="xsd:int"/>
+ <xsd:attribute name="libavformat_version" type="xsd:int"/>
+ <xsd:attribute name="libavdevice_major" type="xsd:int"/>
+ <xsd:attribute name="libavdevice_minor" type="xsd:int"/>
+ <xsd:attribute name="libavdevice_micro" type="xsd:int"/>
+ <xsd:attribute name="libavdevice_version" type="xsd:int"/>
+ <xsd:attribute name="libavfilter_major" type="xsd:int"/>
+ <xsd:attribute name="libavfilter_minor" type="xsd:int"/>
+ <xsd:attribute name="libavfilter_micro" type="xsd:int"/>
+ <xsd:attribute name="libavfilter_version" type="xsd:int"/>
+ <xsd:attribute name="libswscale_major" type="xsd:int"/>
+ <xsd:attribute name="libswscale_minor" type="xsd:int"/>
+ <xsd:attribute name="libswscale_micro" type="xsd:int"/>
+ <xsd:attribute name="libswscale_version" type="xsd:int"/>
+ <xsd:attribute name="libswresample_major" type="xsd:int"/>
+ <xsd:attribute name="libswresample_minor" type="xsd:int"/>
+ <xsd:attribute name="libswresample_micro" type="xsd:int"/>
+ <xsd:attribute name="libswresample_version" type="xsd:int"/>
+ <xsd:attribute name="libpostproc_major" type="xsd:int"/>
+ <xsd:attribute name="libpostproc_minor" type="xsd:int"/>
+ <xsd:attribute name="libpostproc_micro" type="xsd:int"/>
+ <xsd:attribute name="libpostproc_version" type="xsd:int"/>
+ </xsd:complexType>
+
</xsd:schema>
diff --git a/ffprobe.c b/ffprobe.c
index 2746630..819968f 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -24,6 +24,7 @@
*/
#include "config.h"
+#include "version.h"
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
@@ -32,6 +33,9 @@
#include "libavutil/pixdesc.h"
#include "libavutil/dict.h"
#include "libavdevice/avdevice.h"
+#include "libswscale/swscale.h"
+#include "libswresample/swresample.h"
+#include "libpostproc/postprocess.h"
#include "cmdutils.h"
const char program_name[] = "ffprobe";
@@ -41,6 +45,7 @@ static int do_show_error = 0;
static int do_show_format = 0;
static int do_show_packets = 0;
static int do_show_streams = 0;
+static int do_show_version = 0;
static int show_value_unit = 0;
static int use_value_prefix = 0;
@@ -1415,6 +1420,46 @@ static void show_usage(void)
av_log(NULL, AV_LOG_INFO, "\n");
}
+#define SHOW_LIB_VERSION(libname, LIBNAME, flags, level) \
+ { \
+ unsigned int version = libname##_version(); \
+ if (CONFIG_##LIBNAME) { \
+ print_int("lib" #libname "_major", LIB##LIBNAME##_VERSION_MAJOR); \
+ print_int("lib" #libname "_minor", LIB##LIBNAME##_VERSION_MINOR); \
+ print_int("lib" #libname "_micro", LIB##LIBNAME##_VERSION_MICRO); \
+ print_int("lib" #libname "_version", version); \
+ } \
+ }
+
+static void ffprobe_show_version(WriterContext *w)
+{
+ struct print_buf pbuf = {.s = NULL};
+
+ writer_print_chapter_header(w, "version");
+ print_section_header("version");
+ print_str("version", FFMPEG_VERSION);
+ print_fmt("copyright", "Copyright (c) %d-%d the FFmpeg developers",
+ program_birth_year, this_year);
+ print_str("build_date", __DATE__);
+ print_str("build_time", __TIME__);
+ print_str("compiler_type", CC_TYPE);
+ print_str("compiler_version", CC_VERSION);
+ print_str("configuration", FFMPEG_CONFIGURATION);
+
+ SHOW_LIB_VERSION(avutil, AVUTIL, flags, level);
+ SHOW_LIB_VERSION(avcodec, AVCODEC, flags, level);
+ SHOW_LIB_VERSION(avformat, AVFORMAT, flags, level);
+ SHOW_LIB_VERSION(avdevice, AVDEVICE, flags, level);
+ SHOW_LIB_VERSION(avfilter, AVFILTER, flags, level);
+ SHOW_LIB_VERSION(swscale, SWSCALE, flags, level);
+ SHOW_LIB_VERSION(swresample, SWRESAMPLE, flags, level);
+ SHOW_LIB_VERSION(postproc, POSTPROC, flags, level);
+ print_section_footer("version");
+ writer_print_chapter_footer(w, "version");
+
+ av_free(pbuf.s);
+}
+
static int opt_format(const char *opt, const char *arg)
{
iformat = av_find_input_format(arg);
@@ -1475,6 +1520,7 @@ static const OptionDef options[] = {
{ "show_format", OPT_BOOL, {(void*)&do_show_format} , "show format/container info" },
{ "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" },
{ "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" },
+ { "show_version", OPT_BOOL, {(void*)&do_show_version}, "show ffprobe version" },
{ "show_private_data", OPT_BOOL, {(void*)&show_private_data}, "show private data" },
{ "private", OPT_BOOL, {(void*)&show_private_data}, "same as show_private_data" },
{ "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
@@ -1518,12 +1564,19 @@ int main(int argc, char **argv)
if ((ret = writer_open(&wctx, w, w_args, NULL)) >= 0) {
writer_print_header(wctx);
- if (!input_filename) {
+ if (do_show_version)
+ ffprobe_show_version(wctx);
+
+ if (!input_filename &&
+ ((do_show_format || do_show_streams || do_show_packets) ||
+ !do_show_version)) {
show_usage();
av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n");
av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even better, run 'man %s'.\n", program_name);
ret = AVERROR(EINVAL);
- } else
+ }
+
+ if (input_filename)
ret = probe_file(wctx, input_filename);
if (ret < 0 && do_show_error)
--
1.7.5.4
More information about the ffmpeg-devel
mailing list