diff options
Diffstat (limited to 'libmpdemux/demux_lavf.c')
-rw-r--r-- | libmpdemux/demux_lavf.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 5802f1068a..dadf81e146 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -200,7 +200,8 @@ static int lavf_check_file(demuxer_t *demuxer) mp_msg(MSGT_DEMUX, MSGL_WARN, "Stream url is not set!\n"); avpd.filename = ""; } - if (!strncmp(avpd.filename, "ffmpeg://", 9)) + if (!strncmp(avpd.filename, "ffmpeg://", 9) || + !strncmp(avpd.filename, "lavf://", 7)) avpd.filename += 9; avpd.buf_size = probe_data_size; @@ -291,6 +292,8 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) int stream_id; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); AVDictionaryEntry *title = av_dict_get(st->metadata, "title", NULL, 0); + // Work around collisions resulting from the hacks changing codec_tag. + int lavf_codec_tag = codec->codec_tag; // Don't use native MPEG codec tag values with our generic tag tables. // May contain for example value 3 for MP3, which we'd map to PCM audio. if (matches_avinputformat_name(priv, "mpeg") || @@ -319,6 +322,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) stream_type = "audio"; priv->astreams[priv->audio_streams] = i; sh_audio->libav_codec_id = codec->codec_id; + sh_audio->gsh->lavf_codec_tag = lavf_codec_tag; wf = calloc(sizeof(*wf) + codec->extradata_size, 1); // mp4a tag is used for all mp4 files no matter what they actually contain if (codec->codec_tag == MKTAG('m', 'p', '4', 'a')) @@ -331,7 +335,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) wf->nChannels = codec->channels; wf->nSamplesPerSec = codec->sample_rate; wf->nAvgBytesPerSec = codec->bit_rate / 8; - wf->nBlockAlign = codec->block_align ? codec->block_align : 1; + wf->nBlockAlign = codec->block_align; wf->wBitsPerSample = codec->bits_per_coded_sample; wf->cbSize = codec->extradata_size; if (codec->extradata_size) @@ -402,6 +406,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) stream_type = "video"; priv->vstreams[priv->video_streams] = i; sh_video->libav_codec_id = codec->codec_id; + sh_video->gsh->lavf_codec_tag = lavf_codec_tag; bih = calloc(sizeof(*bih) + codec->extradata_size, 1); if (codec->codec_id == CODEC_ID_RAWVIDEO) { @@ -488,8 +493,8 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) case AVMEDIA_TYPE_SUBTITLE: { sh_sub_t *sh_sub; char type; - /* only support text subtitles for now */ - if (codec->codec_id == CODEC_ID_TEXT) + if (codec->codec_id == CODEC_ID_TEXT || + codec->codec_id == AV_CODEC_ID_SUBRIP) type = 't'; else if (codec->codec_id == CODEC_ID_MOV_TEXT) type = 'm'; @@ -516,6 +521,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) stream_type = "subtitle"; priv->sstreams[priv->sub_streams] = i; sh_sub->libav_codec_id = codec->codec_id; + sh_sub->gsh->lavf_codec_tag = lavf_codec_tag; sh_sub->type = type; if (codec->extradata_size) { sh_sub->extradata = malloc(codec->extradata_size); @@ -616,10 +622,12 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) } if (demuxer->stream->url) { - if (!strncmp(demuxer->stream->url, "ffmpeg://rtsp:", 14)) - av_strlcpy(mp_filename, demuxer->stream->url + 9, - sizeof(mp_filename)); - else + 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)); } else av_strlcat(mp_filename, "foobar.dummy", sizeof(mp_filename)); @@ -1004,7 +1012,7 @@ redo: prog->aid = program->stream_index[i]; break; case AVMEDIA_TYPE_SUBTITLE: - if (prog->sid == -2 && priv->avfc->streams[program->stream_index[i]]->codec->codec_id == CODEC_ID_TEXT) + if (prog->sid == -2) prog->sid = program->stream_index[i]; break; } |