MT#55283 set frame size after avcodec_open2

The frame size might not be set before avcodec_open2 is called. Move
setting it to below the call.

Fixes MP3 recording output.

Change-Id: Ie81528e64c2497f769d19a5c54228bf0f5cd138d
pull/1998/head
Richard Fuchs 3 months ago
parent e2e4d8f401
commit 7d37d8b835

@ -1869,11 +1869,6 @@ static const char *avc_encoder_init(encoder_t *enc, const str *extra_opts) {
enc->avc.avcctx->time_base = (AVRational){1,enc->actual_format.clockrate};
enc->avc.avcctx->bit_rate = enc->bitrate;
enc->samples_per_frame = enc->actual_format.clockrate * enc->ptime / 1000;
if (enc->avc.avcctx->frame_size)
enc->samples_per_frame = enc->avc.avcctx->frame_size;
enc->samples_per_packet = enc->samples_per_frame;
if (enc->def->set_enc_options)
enc->def->set_enc_options(enc, extra_opts);
@ -1883,6 +1878,13 @@ static const char *avc_encoder_init(encoder_t *enc, const str *extra_opts) {
return "failed to open output context";
}
if (enc->avc.avcctx->frame_size)
enc->samples_per_frame = enc->avc.avcctx->frame_size;
else
enc->samples_per_frame = enc->actual_format.clockrate * enc->ptime / 1000;
enc->samples_per_packet = enc->samples_per_frame;
return NULL;
}

Loading…
Cancel
Save