private void writeMetadataTag(double duration, Integer videoCodecId, Integer audioCodecId) throws IOException {
metaPosition = channel.position();
ByteBuffer buf = ByteBuffer.allocate(1024);
buf.setAutoExpand(true);
Output out = new Output(buf);
out.writeString("onMetaData");
Map<Object, Object> params = new HashMap<Object, Object>();
params.put("duration", duration);
if (videoCodecId != null) {
params.put("videocodecid", videoCodecId.intValue());
}