According to spec, libvpx should support dynamic resolution changes. Add dynamic resolution encoding support in libvpx.
Format change should also be supported, but I didn't test it so just leave it open. cmdline: ffmpeg -noautoscale -y -i ./reinit-large_420_8-to-small_420_8.h264 -pix_fmt yuv420p -c:v libvpx-vp9 lena.ivf Signed-off-by: Linjie Fu <linjie...@intel.com> --- libavcodec/libvpxenc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index feb52ea..6af6c50 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -1067,6 +1067,15 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt, int res, coded_size; vpx_enc_frame_flags_t flags = 0; + if (frame && (avctx->width != frame->width || + avctx->height != frame->height)) { + avctx->width = frame->width; + avctx->height = frame->height; + + avctx->codec->close(avctx); + avctx->codec->init(avctx); + } + if (frame) { rawimg = &ctx->rawimg; rawimg->planes[VPX_PLANE_Y] = frame->data[0]; @@ -1295,7 +1304,7 @@ AVCodec ff_libvpx_vp8_encoder = { .init = vp8_init, .encode2 = vpx_encode, .close = vpx_free, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_VARIABLE_DIMENSIONS, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE }, .priv_class = &class_vp8, .defaults = defaults, @@ -1325,7 +1334,7 @@ AVCodec ff_libvpx_vp9_encoder = { .init = vp9_init, .encode2 = vpx_encode, .close = vpx_free, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS | AV_CODEC_CAP_VARIABLE_DIMENSIONS, .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), .priv_class = &class_vp9, .defaults = defaults, -- 2.7.4 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".