From db43d515688599c9a4103170f6a8fb205e771327 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Tue, 3 Nov 2020 23:32:15 +0100 Subject: [PATCH] [xcode] Explicitly set the frame duration of OPUS packets to 20 ms Protect against errors in case future versions of ffmpeg change default --- src/transcode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/transcode.c b/src/transcode.c index 77bc9b46..6b4cca61 100644 --- a/src/transcode.c +++ b/src/transcode.c @@ -283,7 +283,7 @@ init_settings(struct settings_ctx *settings, enum transcode_profile profile, str if (quality && quality->bits_per_sample && (quality->bits_per_sample != 8 * av_get_bytes_per_sample(settings->sample_format))) { - DPRINTF(E_LOG, L_XCODE, "Bug! Mismatch between profile and media quality\n"); + DPRINTF(E_LOG, L_XCODE, "Bug! Mismatch between profile (%d bps) and media quality (%d bps)\n", 8 * av_get_bytes_per_sample(settings->sample_format), quality->bits_per_sample); return -1; } @@ -449,6 +449,12 @@ stream_add(struct encode_ctx *ctx, struct stream_ctx *s, enum AVCodecID codec_id if (codec_id == AV_CODEC_ID_MJPEG) av_dict_set(&options, "huffman", "default", 0); + // 20 ms frames is the current ffmpeg default, but we set it anyway, so that + // we don't risk issues if future versions change the default (it would become + // an issue because outputs/cast.c relies on 20 ms frames) + if (codec_id == AV_CODEC_ID_OPUS) + av_dict_set(&options, "frame_duration", "20", 0); + ret = avcodec_open2(s->codec, NULL, &options); if (ret < 0) {