Keep last 30 seconds of encoded frames in a of NAL units. When player dies, flush buffer to disk:
#include "codec_api.h"