[MPlayer-cvslog] r38202 - in trunk: DOCS/man/en/mplayer.1 cfg-common.h stream/stream.h stream/stream_ffmpeg.c

reimar subversion at mplayerhq.hu
Sun Nov 1 17:07:49 EET 2020


Author: reimar
Date: Sun Nov  1 17:07:49 2020
New Revision: 38202

Log:
stream_ffmpeg: add -lavfstreamopts option.

Allows specifying options to ffmpeg-based streams.

Modified:
   trunk/cfg-common.h
   trunk/stream/stream.h
   trunk/stream/stream_ffmpeg.c

Changes in other areas also in this revision:
Modified:
   trunk/DOCS/man/en/mplayer.1

Modified: trunk/cfg-common.h
==============================================================================
--- trunk/cfg-common.h	Sun Nov  1 17:07:47 2020	(r38201)
+++ trunk/cfg-common.h	Sun Nov  1 17:07:49 2020	(r38202)
@@ -546,6 +546,7 @@ const m_option_t common_opts[] = {
 #ifdef CONFIG_FFMPEG
     {"lavdopts", lavc_decode_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
     {"lavfdopts",  lavfdopts_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
+    {"lavfstreamopts",  &lavfstreamopts, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
 #endif
 #ifdef CONFIG_XVID4
     {"xvidopts", xvid_dec_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},

Modified: trunk/stream/stream.h
==============================================================================
--- trunk/stream/stream.h	Sun Nov  1 17:07:47 2020	(r38201)
+++ trunk/stream/stream.h	Sun Nov  1 17:07:49 2020	(r38202)
@@ -392,6 +392,7 @@ extern char *dvd_device;
 extern const m_option_t dvbin_opts_conf[];
 
 extern char *rtsp_destination;
+extern char *lavfstreamopts;
 
 typedef struct {
  int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm

Modified: trunk/stream/stream_ffmpeg.c
==============================================================================
--- trunk/stream/stream_ffmpeg.c	Sun Nov  1 17:07:47 2020	(r38201)
+++ trunk/stream/stream_ffmpeg.c	Sun Nov  1 17:07:49 2020	(r38202)
@@ -27,6 +27,8 @@
 #include "av_helpers.h"
 #include "libmpdemux/demuxer.h"
 
+char *lavfstreamopts;
+
 static int fill_buffer(stream_t *s, char *buffer, int max_len)
 {
     int r = avio_read(s->priv, buffer, max_len);
@@ -90,6 +92,7 @@ static int open_f(stream_t *stream, int
 {
     int flags = 0;
     const char *filename;
+    AVDictionary *avopts = NULL;
     AVIOContext *ctx = NULL;
     int res = STREAM_ERROR;
     int64_t size;
@@ -125,9 +128,23 @@ static int open_f(stream_t *stream, int
     dummy = !strncmp(filename, "rtsp:", 5) || !strncmp(filename, "dummy:", 6);
     mp_msg(MSGT_OPEN, MSGL_V, "[ffmpeg] Opening %s\n", filename);
 
-    if (!dummy && avio_open(&ctx, filename, flags) < 0)
+    if (lavfstreamopts && av_dict_parse_string(&avopts, lavfstreamopts, "=", ",", 0) < 0) {
+        mp_msg(MSGT_HEADER,MSGL_ERR, "Your options /%s/ look like gibberish to me pal\n", lavfstreamopts);
+        goto out;
+    }
+
+    if (!dummy && avio_open2(&ctx, filename, flags, NULL, &avopts) < 0)
         goto out;
 
+    if (!dummy && av_dict_count(avopts)) {
+        AVDictionaryEntry *e = NULL;
+        while ((e = av_dict_get(avopts, "", e, AV_DICT_IGNORE_SUFFIX))) {
+            mp_msg(MSGT_HEADER,MSGL_ERR,"Unknown option %s\n", e->key);
+        }
+        goto out;
+    }
+    av_dict_free(&avopts);
+
     stream->priv = ctx;
     size = dummy ? 0 : avio_size(ctx);
     if (size >= 0)


More information about the MPlayer-cvslog mailing list