diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
index b58a46d..244f63d 100644
--- a/tests/fate/ffmpeg.mak
+++ b/tests/fate/ffmpeg.mak
@@ -99,6 +99,12 @@ fate-h264_mp4toannexb_ticket2991: $(TARGET_SAMPLES)/h264/wwwq_cut.mp4
 fate-h264_mp4toannexb_ticket2991: CMD = transcode "mp4" $(TARGET_SAMPLES)/h264/wwwq_cut.mp4\
                                   h264 "-c:v copy -bsf:v h264_mp4toannexb" "-codec copy"
 
+FATE_SAMPLES_FFMPEG-$(call ALLYES, MOV_DEMUXER H264_MUXER H264_MP4TOANNEXB_BSF) += fate-h264_mp4toannexb_ticket5927 fate-h264_mp4toannexb_ticket5927_2
+fate-h264_mp4toannexb_ticket5927:   CMD = transcode "mp4" $(TARGET_SAMPLES)/h264/thezerotheorem-cut.mp4 \
+                                          h264 "-c:v copy -bsf:v h264_mp4toannexb -an" "-c:v copy"
+fate-h264_mp4toannexb_ticket5927_2: CMD = transcode "mp4" $(TARGET_SAMPLES)/h264/thezerotheorem-cut.mp4 \
+                                          h264 "-c:v copy -an" "-c:v copy"
+
 FATE_SAMPLES_FFMPEG-$(call ALLYES, MPEGPS_DEMUXER AVI_MUXER REMOVE_EXTRADATA_BSF) += fate-ffmpeg-bsf-remove-k fate-ffmpeg-bsf-remove-r fate-ffmpeg-bsf-remove-e
 fate-ffmpeg-bsf-remove-k: $(TARGET_SAMPLES)/mpeg2/matrixbench_mpeg2.lq1.mpg
 fate-ffmpeg-bsf-remove-k: CMD = transcode "mpeg" $(TARGET_SAMPLES)/mpeg2/matrixbench_mpeg2.lq1.mpg\
diff --git a/tests/ref/fate/h264_mp4toannexb_ticket5927 b/tests/ref/fate/h264_mp4toannexb_ticket5927
new file mode 100644
index 0000000..60a1deb
--- /dev/null
+++ b/tests/ref/fate/h264_mp4toannexb_ticket5927
@@ -0,0 +1,21 @@
+a3b02fd09392e01619cebc959d4d9ff2 *tests/data/fate/h264_mp4toannexb_ticket5927.h264
+595583 tests/data/fate/h264_mp4toannexb_ticket5927.h264
+#extradata 0:       59, 0xf10e1136
+#tb 0: 1/1200000
+#media_type 0: video
+#codec_id 0: h264
+#dimensions 0: 1920x1080
+#sar 0: 0/1
+0,     -48000, -9223372036854775808,    48000,   247993, 0x1ce821ea
+0,          0, -9223372036854775808,    48000,    43354, 0xa05dca6f, F=0x0
+0,      48000, -9223372036854775808,    48000,    11423, 0x5e8086dd, F=0x0
+0,      96000, -9223372036854775808,    48000,    50798, 0x145fbe4f, F=0x0
+0,     144000, -9223372036854775808,    48000,    12567, 0x1e3d5304, F=0x0
+0,     192000, -9223372036854775808,    48000,    52444, 0x1a6c1a64, F=0x0
+0,     240000, -9223372036854775808,    48000,    12575, 0x2fff484b, F=0x0
+0,     288000, -9223372036854775808,    48000,    54025, 0xb3bf0ce6, F=0x0
+0,     336000, -9223372036854775808,    48000,    13539, 0xfdb16c57, F=0x0
+0,     384000, -9223372036854775808,    48000,    54483, 0xefead99f, F=0x0
+0,     432000, -9223372036854775808,    48000,    13705, 0x23cd27e8, F=0x0
+0,     480000, -9223372036854775808,    48000,    22308, 0x4093b5af, F=0x0
+0,     528000, -9223372036854775808,    48000,     6369, 0x858b2aa1
diff --git a/tests/ref/fate/h264_mp4toannexb_ticket5927_2 b/tests/ref/fate/h264_mp4toannexb_ticket5927_2
new file mode 100644
index 0000000..b5f11e3
--- /dev/null
+++ b/tests/ref/fate/h264_mp4toannexb_ticket5927_2
@@ -0,0 +1,21 @@
+a3b02fd09392e01619cebc959d4d9ff2 *tests/data/fate/h264_mp4toannexb_ticket5927_2.h264
+595583 tests/data/fate/h264_mp4toannexb_ticket5927_2.h264
+#extradata 0:       59, 0xf10e1136
+#tb 0: 1/1200000
+#media_type 0: video
+#codec_id 0: h264
+#dimensions 0: 1920x1080
+#sar 0: 0/1
+0,     -48000, -9223372036854775808,    48000,   247993, 0x1ce821ea
+0,          0, -9223372036854775808,    48000,    43354, 0xa05dca6f, F=0x0
+0,      48000, -9223372036854775808,    48000,    11423, 0x5e8086dd, F=0x0
+0,      96000, -9223372036854775808,    48000,    50798, 0x145fbe4f, F=0x0
+0,     144000, -9223372036854775808,    48000,    12567, 0x1e3d5304, F=0x0
+0,     192000, -9223372036854775808,    48000,    52444, 0x1a6c1a64, F=0x0
+0,     240000, -9223372036854775808,    48000,    12575, 0x2fff484b, F=0x0
+0,     288000, -9223372036854775808,    48000,    54025, 0xb3bf0ce6, F=0x0
+0,     336000, -9223372036854775808,    48000,    13539, 0xfdb16c57, F=0x0
+0,     384000, -9223372036854775808,    48000,    54483, 0xefead99f, F=0x0
+0,     432000, -9223372036854775808,    48000,    13705, 0x23cd27e8, F=0x0
+0,     480000, -9223372036854775808,    48000,    22308, 0x4093b5af, F=0x0
+0,     528000, -9223372036854775808,    48000,     6369, 0x858b2aa1
