encode: fix expected streams when using --lavfi-complex

mpctx->current_track[0][STREAM_VIDEO] (and STREAM_AUDIO) are empty when
using --lavfi-complex. Moving the muxer stream hinting after audio/video chain
initialization and checking if the chains exist fixes encoding with --lavfi-complex.

Previously, the output audio/video streams did not get prepared and the encode
would fail due to unexpected stream addition.

(cherry picked from commit 3744d0bda9)
This commit is contained in:
TSaaristo 2018-07-05 17:12:46 +03:00 committed by Jan Ekström
parent 5ae13ad13b
commit c994a81aa4
1 changed files with 9 additions and 9 deletions

View File

@ -1296,21 +1296,21 @@ static void play_current_file(struct MPContext *mpctx)
update_demuxer_properties(mpctx);
if (mpctx->encode_lavc_ctx) {
if (mpctx->current_track[0][STREAM_VIDEO])
encode_lavc_expect_stream(mpctx->encode_lavc_ctx, STREAM_VIDEO);
if (mpctx->current_track[0][STREAM_AUDIO])
encode_lavc_expect_stream(mpctx->encode_lavc_ctx, STREAM_AUDIO);
encode_lavc_set_metadata(mpctx->encode_lavc_ctx,
mpctx->demuxer->metadata);
}
update_playback_speed(mpctx);
reinit_video_chain(mpctx);
reinit_audio_chain(mpctx);
reinit_sub_all(mpctx);
if (mpctx->encode_lavc_ctx) {
if (mpctx->vo_chain)
encode_lavc_expect_stream(mpctx->encode_lavc_ctx, STREAM_VIDEO);
if (mpctx->ao_chain)
encode_lavc_expect_stream(mpctx->encode_lavc_ctx, STREAM_AUDIO);
encode_lavc_set_metadata(mpctx->encode_lavc_ctx,
mpctx->demuxer->metadata);
}
if (!mpctx->vo_chain && !mpctx->ao_chain && opts->stream_auto_sel) {
MP_FATAL(mpctx, "No video or audio streams selected.\n");
mpctx->error_playing = MPV_ERROR_NOTHING_TO_PLAY;