Index: mp4property.cpp =================================================================== --- mp4property.cpp (revision 12) +++ mp4property.cpp (working copy) @@ -390,7 +390,9 @@ } if (m_useCountedFormat) { pFile->WriteCountedString(m_values[index], - (m_useUnicode ? 2 : 1), m_useExpandedCount); + (m_useUnicode ? 2 : 1), + m_useExpandedCount, + m_fixedLength); } else if (m_fixedLength) { pFile->WriteBytes((uint8_t*)m_values[index], m_fixedLength); } else { Index: mp4file.h =================================================================== --- mp4file.h (revision 12) +++ mp4file.h (working copy) @@ -644,7 +644,9 @@ void WriteFloat(float value); void WriteString(char* string); void WriteCountedString(char* string, - uint8_t charSize = 1, bool allowExpandedCount = false); + uint8_t charSize = 1, + bool allowExpandedCount = false, + uint8_t fixedLength = 0); void WriteBits(uint64_t bits, uint8_t numBits); void PadWriteBits(uint8_t pad = 0); void FlushWriteBits(); Index: atom_avc1.cpp =================================================================== --- atom_avc1.cpp (revision 12) +++ atom_avc1.cpp (working copy) @@ -41,6 +41,7 @@ MP4StringProperty* pProp = new MP4StringProperty("compressorName"); pProp->SetFixedLength(32); + pProp->SetCountedFormat(true); pProp->SetValue("AVC Coding"); AddProperty(pProp); /* 6 */ Index: atom_mp4v.cpp =================================================================== --- atom_mp4v.cpp (revision 12) +++ atom_mp4v.cpp (working copy) @@ -41,6 +41,7 @@ MP4StringProperty* pProp = new MP4StringProperty("compressorName"); pProp->SetFixedLength(32); + pProp->SetCountedFormat(true); pProp->SetValue(""); AddProperty(pProp); /* 6 */ Index: atom_encv.cpp =================================================================== --- atom_encv.cpp (revision 12) +++ atom_encv.cpp (working copy) @@ -41,7 +41,8 @@ MP4StringProperty* pProp = new MP4StringProperty("compressorName"); - pProp->SetFixedLength(32); + pProp->SetFixedLength(32); + pProp->SetCountedFormat(true); pProp->SetValue(""); AddProperty(pProp); /* 6 */ AddReserved("reserved4", 4); /* 7 */ Index: mp4file_io.cpp =================================================================== --- mp4file_io.cpp (revision 12) +++ mp4file_io.cpp (working copy) @@ -443,11 +443,17 @@ } void MP4File::WriteCountedString(char* string, - uint8_t charSize, bool allowExpandedCount) + uint8_t charSize, bool allowExpandedCount, + uint8_t fixedLength) { uint32_t byteLength; + uint8_t zero[1]; + if (string) { byteLength = strlen(string); + if (byteLength >= fixedLength) { + byteLength = fixedLength-1; + } } else { byteLength = 0; } @@ -458,16 +464,27 @@ WriteUInt8(0xFF); charLength -= 0xFF; } + // Write the count WriteUInt8(charLength); } else { if (charLength > 255) { throw new MP4Error(ERANGE, "Length is %d", "MP4WriteCountedString", charLength); } + // Write the count WriteUInt8(charLength); } if (byteLength > 0) { - WriteBytes((uint8_t*)string, byteLength); + // Write the string (or the portion that we want to write) + WriteBytes((uint8_t*)string, byteLength); + // Write any padding if this is a fixed length counted string + if (fixedLength) { + zero[0] = 0; + while (byteLength < fixedLength-1) { + WriteBytes(zero, 1); + byteLength++; + } + } } } Index: atom_video.cpp =================================================================== --- atom_video.cpp (revision 12) +++ atom_video.cpp (working copy) @@ -41,6 +41,7 @@ MP4StringProperty* pProp = new MP4StringProperty("compressorName"); pProp->SetFixedLength(32); + pProp->SetCountedFormat(true); pProp->SetValue(""); AddProperty(pProp); /* 6 */