mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace use of deprecated ffmpeg API
This commit is contained in:
parent
e6bf1a6d86
commit
3e1a9ec3e7
@ -239,7 +239,14 @@ open_output_file(Transcoder *t) {
|
|||||||
// Setup encoding parameters
|
// Setup encoding parameters
|
||||||
av_channel_layout_default(&t->enc_ctx->ch_layout, t->dec_ctx->ch_layout.nb_channels);
|
av_channel_layout_default(&t->enc_ctx->ch_layout, t->dec_ctx->ch_layout.nb_channels);
|
||||||
t->enc_ctx->sample_rate = t->dec_ctx->sample_rate;
|
t->enc_ctx->sample_rate = t->dec_ctx->sample_rate;
|
||||||
|
int ret;
|
||||||
|
#if LIBAVCODEC_VERSION_MAJOR >= 61
|
||||||
|
const enum AVSampleFormat *sample_fmts = NULL;
|
||||||
|
ret = avcodec_get_supported_config(t->dec_ctx, output_codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void**)&sample_fmts, NULL);
|
||||||
|
t->enc_ctx->sample_fmt = (ret >= 0 && sample_fmts) ? sample_fmts[0] : t->dec_ctx->sample_fmt;
|
||||||
|
#else
|
||||||
t->enc_ctx->sample_fmt = output_codec->sample_fmts[0];
|
t->enc_ctx->sample_fmt = output_codec->sample_fmts[0];
|
||||||
|
#endif
|
||||||
t->enc_ctx->bit_rate = t->output_bitrate;
|
t->enc_ctx->bit_rate = t->output_bitrate;
|
||||||
if (!t->enc_ctx->bit_rate) {
|
if (!t->enc_ctx->bit_rate) {
|
||||||
switch (output_codec->id) {
|
switch (output_codec->id) {
|
||||||
@ -252,7 +259,6 @@ open_output_file(Transcoder *t) {
|
|||||||
stream->time_base.den = t->dec_ctx->sample_rate;
|
stream->time_base.den = t->dec_ctx->sample_rate;
|
||||||
stream->time_base.num = 1;
|
stream->time_base.num = 1;
|
||||||
if (t->ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) t->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
if (t->ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER) t->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||||
int ret;
|
|
||||||
check_call(avcodec_open2, t->enc_ctx, output_codec, NULL);
|
check_call(avcodec_open2, t->enc_ctx, output_codec, NULL);
|
||||||
check_call(avcodec_parameters_from_context, stream->codecpar, t->enc_ctx);
|
check_call(avcodec_parameters_from_context, stream->codecpar, t->enc_ctx);
|
||||||
return Py_True;
|
return Py_True;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user