avformat: split muxing functions from util.c