h264: Add user unregistered SEI message
<p>I'm trying to write a NAL unit with a SEI user data message. My code looks like:</p>

<pre><code>typedef struct {
    unsigned char type_code;
    unsigned char countryCode;
    unsigned char countryCodeExtension[2];
    unsigned char user_identifier[4];
    unsigned char payloadBytes[20];
    unsigned char marker_bits;
} userdata_reg_t35;

unsigned char begin[5] = {0x00, 0x00, 0x00, 0x01, 0x06};
unsigned char end[3] = {0x00, sizeof(userdata_reg_t35), 0x80};

userdata_reg_t35 m_userSEIData;
m_userSEIData.countryCode = 0xB5;
m_userSEIData.countryCodeExtension[0] = 0x31;
m_userSEIData.countryCodeExtension[1] = 0x00;
m_userSEIData.user_identifier[0] = 0x34;
m_userSEIData.user_identifier[1] = 0x39;
m_userSEIData.user_identifier[2] = 0x41;
m_userSEIData.user_identifier[3] = 0x47;
m_userSEIData.type_code = 0x03;
m_userSEIData.marker_bits = 0xFF;
sprintf((char*)m_userSEIData.payloadBytes, "%s", "My Payload");

memcpy(target, begin, 5);
memcpy(target + 5, &amp;m_userSEIData, sizeof(userdata_reg_t35));
memcpy(target + 5 + sizeof(userdata_reg_t35), end, 3);
</code></pre>

<p>When I playback the file in mplayer or vlc, I receive errors:</p>

<pre><code>[h264 @ 0x7f5860c20720] SEI type 3 truncated at 216
</code></pre>

<p>What am I doing wrong?</p>

<p>** <strong>EDIT</strong> **</p>

<p>I have modified the code after reading <a href="http://git.videolan.org/?p=x264.git;a=blob;f=encoder/set.c#l563" rel="nofollow">http://git.videolan.org/?p=x264.git;a=blob;f=encoder/set.c#l563</a></p>

<pre><code>static const uint8_t uuid[16] = {0xdc, 0x45, 0xe9, 0xbd, 0xe6, 0xd9, 0x48, 0xb7,
    0x96, 0x2c, 0xd8, 0x20, 0xd9, 0x23, 0xee, 0xef};
unsigned char begin[7] = {0x00, 0x00, 0x00, 0x01, 0x06, 0x05, 16 + 20};
char szPayload[20];
memset(szPayload, 0, 20);
sprintf(szPayload, "%s", "My payload");
memcpy(target, begin, 7);
memcpy(target + 7, uuid, 16);
memcpy(target + 7 + 16, szPayload, 20);
</code></pre>

<p>but I'm still getting the libav error: <a href="https://ffmpeg.org/doxygen/2.6/h264__sei_8c_source.html" rel="nofollow">https://ffmpeg.org/doxygen/2.6/h264__sei_8c_source.html</a>, line #306. What am I still doing wrong?</p>