From aa2c07542f11ee8ab6df0949635ee453952213dd Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 30 Nov 2012 17:59:55 +0100 Subject: [PATCH] demux_lavf: do not prefix filename passed to libavformat with "mp:" Opening files with the libavformat AVISynth demuxer ("avs"/avisynth.c) fails, because the filename we pass to avformat_open_input() is prefixed with "mp:". Normally, this doesn't matter, because data is read with the stream interface. The AVISynth demuxer can't use this, because the Avisynth API (apparently) can't read scripts from memory, and requires a filename. The "mp:" prefix used to be required when mplayer's stream layer was made available as protocol to ffmpeg. This was replaced by setting custom stream callbacks in de4908 (svn commit 25499), but the prefix wasn't removed. Since this prefix doesn't have any purpose anymore and prevents AVS playback from functioning, remove it. Fixes #5. --- demux/demux_lavf.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 85fa2a9be1..ad4f521052 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -578,7 +578,6 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) AVDictionaryEntry *t = NULL; lavf_priv_t *priv = demuxer->priv; int i; - char mp_filename[256] = "mp:"; stream_seek(demuxer->stream, 0); @@ -620,16 +619,18 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) } } - if (demuxer->stream->url) { + char *filename = demuxer->stream->url; + + if (filename) { if (demuxer->stream->lavf_type && !strcmp(demuxer->stream->lavf_type, "rtsp")) { // Remove possible leading ffmpeg:// or lavf:// - char *name = strstr(demuxer->stream->url, "rtsp:"); - av_strlcpy(mp_filename, name, sizeof(mp_filename)); - } else - av_strlcat(mp_filename, demuxer->stream->url, sizeof(mp_filename)); + char *name = strstr(filename, "rtsp:"); + if (name) + filename = name; + } } else - av_strlcat(mp_filename, "foobar.dummy", sizeof(mp_filename)); + filename = "mp:unknown"; if (!(priv->avif->flags & AVFMT_NOFILE)) { priv->pb = avio_alloc_context(priv->buffer, BIO_BUFFER_SIZE, 0, @@ -641,7 +642,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) avfc->pb = priv->pb; } - if (avformat_open_input(&avfc, mp_filename, priv->avif, NULL) < 0) { + if (avformat_open_input(&avfc, filename, priv->avif, NULL) < 0) { mp_msg(MSGT_HEADER, MSGL_ERR, "LAVF_header: avformat_open_input() failed\n"); return NULL;