mirror of
https://github.com/mpv-player/mpv
synced 2025-01-13 18:45:25 +00:00
encode: update to current ffmpeg API
This gets rid of some quite ugly code.
This commit is contained in:
parent
a89a6f40c7
commit
53c6a7480f
@ -140,35 +140,13 @@ struct encode_lavc_context *encode_lavc_init(struct encode_output_conf *options)
|
||||
encode_lavc_discontinuity(ctx);
|
||||
ctx->options = options;
|
||||
|
||||
ctx->avc = avformat_alloc_context();
|
||||
|
||||
if (ctx->options->format) {
|
||||
char *tok;
|
||||
const char *in = ctx->options->format;
|
||||
while (*in) {
|
||||
tok = av_get_token(&in, ",");
|
||||
ctx->vc = avcodec_find_encoder_by_name(tok);
|
||||
ctx->avc->oformat = av_guess_format(tok, ctx->options->file, NULL);
|
||||
av_free(tok);
|
||||
if (ctx->avc->oformat)
|
||||
ctx->vc = NULL;
|
||||
if (ctx->vc)
|
||||
break;
|
||||
if (*in)
|
||||
++in;
|
||||
}
|
||||
} else {
|
||||
ctx->avc->oformat = av_guess_format(NULL, ctx->options->file, NULL);
|
||||
}
|
||||
|
||||
if (!ctx->avc->oformat) {
|
||||
encode_lavc_fail(ctx, "encode-lavc: format not found\n");
|
||||
ctx->avc = NULL;
|
||||
avformat_alloc_output_context2(&ctx->avc, NULL, ctx->options->format, ctx->options->file);
|
||||
if (!ctx->avc) {
|
||||
encode_lavc_fail(ctx, "encode-lavc: avformat context allocation failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
av_strlcpy(ctx->avc->filename, ctx->options->file,
|
||||
sizeof(ctx->avc->filename));
|
||||
|
||||
ctx->foptions = NULL;
|
||||
if (ctx->options->fopts) {
|
||||
char **p;
|
||||
@ -469,7 +447,8 @@ AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx,
|
||||
encode_lavc_fail(ctx, "vo-lavc: encoder not found\n");
|
||||
return NULL;
|
||||
}
|
||||
stream = avformat_new_stream(ctx->avc, ctx->vc);
|
||||
stream = avformat_new_stream(ctx->avc, NULL);
|
||||
avcodec_get_context_defaults3(stream->codec, ctx->vc);
|
||||
|
||||
// stream->time_base = ctx->timebase;
|
||||
// doing this breaks mpeg2ts in ffmpeg
|
||||
@ -519,7 +498,8 @@ AVStream *encode_lavc_alloc_stream(struct encode_lavc_context *ctx,
|
||||
encode_lavc_fail(ctx, "ao-lavc: encoder not found\n");
|
||||
return NULL;
|
||||
}
|
||||
stream = avformat_new_stream(ctx->avc, ctx->ac);
|
||||
stream = avformat_new_stream(ctx->avc, NULL);
|
||||
avcodec_get_context_defaults3(stream->codec, ctx->ac);
|
||||
|
||||
stream->codec->codec_id = ctx->ac->id;
|
||||
stream->codec->time_base = ctx->timebase;
|
||||
|
Loading…
Reference in New Issue
Block a user