Skip to content

Commit ca0a37c

Browse files
author
reimar
committed
stream_ffmpeg: add -lavfstreamopts option.
Allows specifying options to ffmpeg-based streams. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@38202 b3059339-0415-0410-9bf9-f77b7e298cf2
1 parent 11cc16e commit ca0a37c

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

DOCS/man/en/mplayer.1

+4
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,10 @@ Skip the proxy for IPv6 addresses.
18121812
It will still be used for IPv4 connections.
18131813
.
18141814
.TP
1815+
.B \-lavfstreamopts <options>
1816+
Specify extra options for libavformat based streams.
1817+
.
1818+
.TP
18151819
.B \-loadidx <index file>
18161820
The file from which to read the video index data saved by \-saveidx.
18171821
This index will be used for seeking, overriding any index data

cfg-common.h

+1
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ const m_option_t common_opts[] = {
546546
#ifdef CONFIG_FFMPEG
547547
{"lavdopts", lavc_decode_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
548548
{"lavfdopts", lavfdopts_conf, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
549+
{"lavfstreamopts", &lavfstreamopts, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
549550
#endif
550551
#ifdef CONFIG_XVID4
551552
{"xvidopts", xvid_dec_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},

stream/stream.h

+1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ extern char *dvd_device;
392392
extern const m_option_t dvbin_opts_conf[];
393393

394394
extern char *rtsp_destination;
395+
extern char *lavfstreamopts;
395396

396397
typedef struct {
397398
int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm

stream/stream_ffmpeg.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "av_helpers.h"
2828
#include "libmpdemux/demuxer.h"
2929

30+
char *lavfstreamopts;
31+
3032
static int fill_buffer(stream_t *s, char *buffer, int max_len)
3133
{
3234
int r = avio_read(s->priv, buffer, max_len);
@@ -90,6 +92,7 @@ static int open_f(stream_t *stream, int mode, void *opts, int *file_format)
9092
{
9193
int flags = 0;
9294
const char *filename;
95+
AVDictionary *avopts = NULL;
9396
AVIOContext *ctx = NULL;
9497
int res = STREAM_ERROR;
9598
int64_t size;
@@ -125,9 +128,23 @@ static int open_f(stream_t *stream, int mode, void *opts, int *file_format)
125128
dummy = !strncmp(filename, "rtsp:", 5) || !strncmp(filename, "dummy:", 6);
126129
mp_msg(MSGT_OPEN, MSGL_V, "[ffmpeg] Opening %s\n", filename);
127130

128-
if (!dummy && avio_open(&ctx, filename, flags) < 0)
131+
if (lavfstreamopts && av_dict_parse_string(&avopts, lavfstreamopts, "=", ",", 0) < 0) {
132+
mp_msg(MSGT_HEADER,MSGL_ERR, "Your options /%s/ look like gibberish to me pal\n", lavfstreamopts);
133+
goto out;
134+
}
135+
136+
if (!dummy && avio_open2(&ctx, filename, flags, NULL, &avopts) < 0)
129137
goto out;
130138

139+
if (!dummy && av_dict_count(avopts)) {
140+
AVDictionaryEntry *e = NULL;
141+
while ((e = av_dict_get(avopts, "", e, AV_DICT_IGNORE_SUFFIX))) {
142+
mp_msg(MSGT_HEADER,MSGL_ERR,"Unknown option %s\n", e->key);
143+
}
144+
goto out;
145+
}
146+
av_dict_free(&avopts);
147+
131148
stream->priv = ctx;
132149
size = dummy ? 0 : avio_size(ctx);
133150
if (size >= 0)

0 commit comments

Comments
 (0)