diff options
author | Rudolf Polzer <divVerent@xonotic.org> | 2014-05-16 21:41:32 +0200 |
---|---|---|
committer | Rudolf Polzer <divVerent@xonotic.org> | 2014-05-16 21:41:32 +0200 |
commit | 4ac4269389cda8a5fc4e8133d1046b93641e2d3b (patch) | |
tree | f06903def301bf18bff01cb58c0a7e542ce16253 /common | |
parent | 129ab5833d06e91599d538c48d3c6fbb63993b83 (diff) | |
download | mpv-4ac4269389cda8a5fc4e8133d1046b93641e2d3b.tar.bz2 mpv-4ac4269389cda8a5fc4e8133d1046b93641e2d3b.tar.xz |
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.
Diffstat (limited to 'common')
-rw-r--r-- | common/encode_lavc.c | 28 |
1 files changed, 20 insertions, 8 deletions
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); |