diff options
author | wm4 <wm4@nowhere> | 2012-12-10 01:28:20 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-12-11 00:37:54 +0100 |
commit | 180944fe282fb57be4d8f986f7fcb0a209f943d5 (patch) | |
tree | 0a25fd0b88429c57f54019deb2d9801bf51c0224 /stream/stream_lavf.c | |
parent | 222a5cf7c0a4de094f368f7154122a72312dbf39 (diff) | |
download | mpv-180944fe282fb57be4d8f986f7fcb0a209f943d5.tar.bz2 mpv-180944fe282fb57be4d8f986f7fcb0a209f943d5.tar.xz |
stream_lavf/demux_lavf: export/use HTTP MIME type
This is a fix for web radio streams that send raw AAC [1]. libavformat's
AAC demuxer probe is picky enough to request hundreds of KBs data, which
makes for a slow startup. To speed up stream startup, try use the HTTP
MIME type to identify the format. The webstream in question sends an AAC
specific MIME type, for which demux_lavf will force the AAC demuxer,
without probing anything.
ffmpeg/ffplay do the same thing. Note that as of ffmpeg commit 76d851b,
av_probe_input_buffer() does the mapping from MIME type to demuxer. The
actual mapping is not publicly accessible, and can only be used by
calling that function. This will hopefully be rectified, and ideally
ffmpeg would provide a function like find_demuxer_from_mime_type().
[1] http://lr2mp0.latvijasradio.lv:8000
Diffstat (limited to 'stream/stream_lavf.c')
-rw-r--r-- | stream/stream_lavf.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index a3268c10ae..4dae59c2c0 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -16,10 +16,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" +#include <libavformat/avformat.h> +#include <libavformat/avio.h> +#include <libavutil/opt.h> -#include "libavformat/avformat.h" -#include "libavformat/avio.h" +#include "config.h" #include "core/mp_msg.h" #include "stream.h" #include "core/m_option.h" @@ -139,6 +140,12 @@ static int open_f(stream_t *stream, int mode, void *opts, int *file_format) if (avio_open(&avio, filename, flags) < 0) goto out; + if (avio->av_class) { + uint8_t *mt = NULL; + if (av_opt_get(avio, "mime_type", AV_OPT_SEARCH_CHILDREN, &mt) >= 0) + stream->mime_type = talloc_strdup(stream, mt); + } + char *rtmp[] = {"rtmp:", "rtmpt:", "rtmpe:", "rtmpte:", "rtmps:"}; for (int i = 0; i < FF_ARRAY_ELEMS(rtmp); i++) if (!strncmp(filename, rtmp[i], strlen(rtmp[i]))) { |