Index: ffmpeg-2.3.3/libavformat/mpegtsenc.c
===================================================================
--- ffmpeg-2.3.3.orig/libavformat/mpegtsenc.c	2014-08-17 17:33:15.000000000 +0400
+++ ffmpeg-2.3.3/libavformat/mpegtsenc.c	2014-08-27 11:39:49.554649472 +0400
@@ -1145,14 +1145,16 @@
 
 int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt)
 {
-    if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) {
-        if (!st->nb_frames) {
-            av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
-                   "no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)\n");
-            return AVERROR(EINVAL);
-        }
-        av_log(s, AV_LOG_WARNING, "H.264 bitstream error, startcode missing\n");
+    if ((pkt->size > 4 && AV_RB32(pkt->data) == 0x00000001) || (pkt->size >= 4 && AV_RB24(pkt->data) == 0x000001))
+        return 0;
+
+    if (!st->nb_frames) {
+        av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
+               "no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)\n");
+        return AVERROR(EINVAL);
     }
+    av_log(s, AV_LOG_WARNING, "H.264 bitstream error, startcode missing\n");
+
     return 0;
 }
 
