Backported improvements from the flvmeta project.