diff -up ./modules/stream_out/rtp.c.rtp_h264_startcode ./modules/stream_out/rtp.c
--- ./modules/stream_out/rtp.c.rtp_h264_startcode	2010-04-15 02:03:12.000000000 +0400
+++ ./modules/stream_out/rtp.c	2010-04-21 17:34:47.000000000 +0400
@@ -1188,37 +1188,69 @@ static sout_stream_id_t *Add( sout_strea
                 char    *p_64_pps = NULL;
                 char    hexa[6+1];
 
-                while( i_buffer > 4 &&
-                       p_buffer[0] == 0 && p_buffer[1] == 0 &&
-                       p_buffer[2] == 0 && p_buffer[3] == 1 )
+				/* NAL start code: 00 ... 00 00 01 (atleast 00 00 01) */
+                while( i_buffer >= 4 )
                 {
-                    const int i_nal_type = p_buffer[4]&0x1f;
-                    int i_offset;
-                    int i_size      = 0;
+                    int i_size = 0; /* current NAL unit size */
+					int i_nal_type;
 
-                    msg_Dbg( p_stream, "we found a startcode for NAL with TYPE:%d", i_nal_type );
+					/* Split start code zeros */
+					while (i_buffer > 0 && 0 == *p_buffer)
+					{
+						--i_buffer;
+						++p_buffer;
+					}
+
+					if ( 0 == i_buffer || 1 != *p_buffer)
+					{
+						/* Start code not found */				
+	                    msg_Warn( p_stream, "No H264/NAL start code found");
+						break;
+					}
+
+					/* p_buffer/i_buffer starts from 1st data byte */
+					--i_buffer;
+					++p_buffer;
 
+					/* Search the next start code */
                     i_size = i_buffer;
-                    for( i_offset = 4; i_offset+3 < i_buffer ; i_offset++)
+                    for(int i_offset = 0; i_offset+2 < i_buffer ; ++i_offset)
                     {
-                        if( !memcmp (p_buffer + i_offset, "\x00\x00\x00\x01", 4 ) )
+                        if( !memcmp (p_buffer + i_offset, "\x00\x00\x01", 3 ) )
                         {
-                            /* we found another startcode */
+							while ( i_offset > 0 && 0 == p_buffer[i_offset-1] )
+							{
+								--i_offset;
+							}
+
+                            /* we found another startcode's start byte */
                             i_size = i_offset;
                             break;
                         }
                     }
+
+					if ( 0 == i_size )
+					{
+	                    msg_Warn( p_stream, "H264 NAL without any data");
+						continue;
+					}
+					
+					/* Parse NAL Unit*/
+                    i_nal_type = p_buffer[0] & 0x1f;
+                   	msg_Dbg( p_stream, "We found a startcode for NAL with TYPE:%d", i_nal_type );
+
                     if( i_nal_type == 7 )
-                    {
-                        p_64_sps = vlc_b64_encode_binary( &p_buffer[4], i_size - 4 );
-                        sprintf_hexa( hexa, &p_buffer[5], 3 );
-                    }
+   	                {
+       	                p_64_sps = vlc_b64_encode_binary( p_buffer, i_size );
+           	            sprintf_hexa( hexa, &p_buffer[5], 3 );
+   	                }
                     else if( i_nal_type == 8 )
-                    {
-                        p_64_pps = vlc_b64_encode_binary( &p_buffer[4], i_size - 4 );
-                    }
-                    i_buffer -= i_size;
-                    p_buffer += i_size;
+   	                {
+       	                p_64_pps = vlc_b64_encode_binary( p_buffer, i_size );
+   	                }
+
+               	    i_buffer -= i_size;
+                   	p_buffer += i_size;
                 }
                 /* */
                 if( p_64_sps && p_64_pps &&
