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.
This commit is contained in:
wm4 2012-11-30 17:59:55 +01:00
parent 3b4682183c
commit aa2c07542f
1 changed files with 9 additions and 8 deletions

View File

@ -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;