@Override
    public OggPacket write() {
        int len = 64;
        if (versionMajor == 4) {
            len = 80;
        }
        byte[] data = new byte[len];

        IOUtils.putUTF8(data, 0, MAGIC_FISHEAD_STR);
        IOUtils.putInt2(data, 8, versionMajor);
        IOUtils.putInt2(data, 10, versionMinor);

        IOUtils.putInt8(data, 12, presentationTimeNumerator);
        IOUtils.putInt8(data, 20, presentationTimeDenominator);
        IOUtils.putInt8(data, 28, baseTimeNumerator);
        IOUtils.putInt8(data, 36, baseTimeDenominator);

        if (utc != null) {
            IOUtils.putUTF8(data, 44, utc);
        } else {
            // Leave as all zeros
        }

        if (versionMajor == 4) {
            IOUtils.putInt8(data, 64, segmentLength);
            IOUtils.putInt8(data, 72, contentOffset);
        }

        setData(data);
        return super.write();
    }