From 4ac4269389cda8a5fc4e8133d1046b93641e2d3b Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 16 May 2014 21:41:32 +0200 Subject: encoding: No error when the output format doesn't support a stream type at all. When writing a video to foo.mp3, the user's intention is clearly to drop the video stream, and similarly, when writing to foo-%d.png, the intention is clearly to drop the audio stream. Now, explicit specification of --no-audio or --no-video is no longer necessary in these cases. --- common/encode_lavc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'common/encode_lavc.c') diff --git a/common/encode_lavc.c b/common/encode_lavc.c index 78bbfeb84d..0ec3e93b06 100644 --- a/common/encode_lavc.c +++ b/common/encode_lavc.c @@ -268,9 +268,12 @@ int encode_lavc_start(struct encode_lavc_context *ctx) if (ctx->avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) break; if (i >= ctx->avc->nb_streams) { - encode_lavc_fail(ctx, - "video stream missing, invalid codec?\n"); - return 0; + if (ctx->avc->oformat->video_codec != AV_CODEC_ID_NONE || + ctx->options->vcodec) { + encode_lavc_fail(ctx, + "no video stream succeeded - invalid codec?\n"); + return 0; + } } } if (ctx->expect_audio) { @@ -279,9 +282,12 @@ int encode_lavc_start(struct encode_lavc_context *ctx) if (ctx->avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) break; if (i >= ctx->avc->nb_streams) { - encode_lavc_fail(ctx, - "audio stream missing, invalid codec?\n"); - return 0; + if (ctx->avc->oformat->audio_codec != AV_CODEC_ID_NONE || + ctx->options->acodec) { + encode_lavc_fail(ctx, + "no audio stream succeeded - invalid codec?\n"); + return 0; + } } } @@ -545,7 +551,10 @@ AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx, switch (mt) { case AVMEDIA_TYPE_VIDEO: if (!ctx->vc) { - encode_lavc_fail(ctx, "vo-lavc: encoder not found\n"); + if (ctx->avc->oformat->video_codec != AV_CODEC_ID_NONE || + ctx->options->vcodec) { + encode_lavc_fail(ctx, "vo-lavc: encoder not found\n"); + } return NULL; } avcodec_get_context_defaults3(stream->codec, ctx->vc); @@ -578,7 +587,10 @@ AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx, case AVMEDIA_TYPE_AUDIO: if (!ctx->ac) { - encode_lavc_fail(ctx, "ao-lavc: encoder not found\n"); + if (ctx->avc->oformat->audio_codec != AV_CODEC_ID_NONE || + ctx->options->acodec) { + encode_lavc_fail(ctx, "ao-lavc: encoder not found\n"); + } return NULL; } avcodec_get_context_defaults3(stream->codec, ctx->ac); -- cgit v1.2.3