[MPlayer-dev-eng] [PATCH] lavf demuxer select and list formats

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Mon Feb 5 15:25:13 CET 2007


Hello,
attached patch adds lavfdopts format suboption which allows forcing a
specific format or to list available ones by specifying "help".
Any objections (besides missing man page part)?

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_lavf.c
===================================================================
--- libmpdemux/demux_lavf.c	(revision 22133)
+++ libmpdemux/demux_lavf.c	(working copy)
@@ -46,9 +46,11 @@
 
 extern char *audio_lang;
 static unsigned int opt_probesize = 0;
+static char *opt_format;
 
 m_option_t lavfdopts_conf[] = {
 	{"probesize", &(opt_probesize), CONF_TYPE_INT, CONF_RANGE, 32, INT_MAX, NULL},
+	{"format",    &(opt_format),    CONF_TYPE_STRING,       0,  0,       0, NULL},
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
@@ -156,6 +158,13 @@
     mp_close,
 };
 
+static void list_formats(void) {
+    AVInputFormat *fmt;
+    mp_msg(MSGT_DEMUX, MSGL_INFO, "Available lavf input formats:\n");
+    for (fmt = first_iformat; fmt; fmt = fmt->next)
+        mp_msg(MSGT_DEMUX, MSGL_INFO, "%15s : %s\n", fmt->name, fmt->long_name);
+}
+
 static int lavf_check_file(demuxer_t *demuxer){
     AVProbeData avpd;
     uint8_t buf[PROBE_BUF_SIZE];
@@ -173,6 +182,19 @@
     avpd.buf= buf;
     avpd.buf_size= PROBE_BUF_SIZE;
 
+    if (opt_format) {
+        if (strcmp(opt_format, "help") == 0) {
+           list_formats();
+           return 0;
+        }
+        priv->avif= av_find_input_format(opt_format);
+        if (!priv->avif) {
+            mp_msg(MSGT_DEMUX,MSGL_FATAL,"Unknown lavf format %s\n", opt_format);
+            return 0;
+        }
+        mp_msg(MSGT_DEMUX,MSGL_INFO,"Forced lavf %s demuxer\n", priv->avif->long_name);
+        return DEMUXER_TYPE_LAVF;
+    }
     priv->avif= av_probe_input_format(&avpd, 1);
     if(!priv->avif){
         mp_msg(MSGT_HEADER,MSGL_V,"LAVF_check: no clue about this gibberish!\n");


More information about the MPlayer-dev-eng mailing list