Did you find any solution? libx264 now have flag AV_CODEC_CAP_ENCODER_FLUSH for x264
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/libx264.c
But I can't understand - how make it working. When I use avcodec_flush_buffers then after switching to next stream I just got in log
lookahead thread is already stopped
Error sending video frame for encoding: Generic error in an external library