diff --git a/tests/Makefile b/tests/Makefile
index 8e810ff..e23260f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -164,6 +164,7 @@ include $(SRC_PATH)/tests/fate/real.mak
 include $(SRC_PATH)/tests/fate/screen.mak
 include $(SRC_PATH)/tests/fate/source.mak
 include $(SRC_PATH)/tests/fate/subtitles.mak
+include $(SRC_PATH)/tests/fate/tee-muxer.mak
 include $(SRC_PATH)/tests/fate/utvideo.mak
 include $(SRC_PATH)/tests/fate/video.mak
 include $(SRC_PATH)/tests/fate/voice.mak
diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index c640cc5..9c90ea5 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -73,6 +73,12 @@ oneline(){
     printf '%s\n' "$1" | diff -u -b - "$2"
 }
 
+multidiff(){
+    while read -r ref_file out_file; do
+        diff -u -b "${base}/ref/fate/${ref_file}" "${outdir}/${out_file}" || return $?
+    done <"$1"
+}
+
 run(){
     test "${V:-0}" -gt 0 && echo "$target_exec" $target_path/"$@" >&3
     $target_exec $target_path/"$@"
@@ -350,6 +356,7 @@ if test -e "$ref" || test $cmp = "oneline" || test $cmp = "grep" ; then
     case $cmp in
         diff)   diff -u -b "$ref" "$outfile"            >$cmpfile ;;
         rawdiff)diff -u    "$ref" "$outfile"            >$cmpfile ;;
+        mdiff)  multidiff  "$ref"                       >$cmpfile ;;
         oneoff) oneoff     "$ref" "$outfile"            >$cmpfile ;;
         stddev) stddev     "$ref" "$outfile"            >$cmpfile ;;
         oneline)oneline    "$ref" "$outfile"            >$cmpfile ;;
diff --git a/tests/fate/tee-muxer.mak b/tests/fate/tee-muxer.mak
new file mode 100644
index 0000000..b760ea1
--- /dev/null
+++ b/tests/fate/tee-muxer.mak
@@ -0,0 +1,22 @@
+fate-tee-muxer-h264: CMD = ffmpeg -i $(TARGET_SAMPLES)/mkv/1242-small.mkv -vframes 11\
+                           -c:v copy -c:a copy -map v:0 -map a:0 -flags +bitexact\
+                           -fflags +bitexact -fflags +bitexact -f tee\
+			   "[f=framecrc]$(SRC_PATH)/tests/data/fate/tee-muxer-h264-copy|[f=framecrc:select=1]$(SRC_PATH)/tests/data/fate/tee-muxer-h264-audio"
+fate-tee-muxer-h264: CMP = mdiff
+FATE-SAMPLES-TEE-MUXER-$(call ALLYES, TEE_MUXER, MATROSKA_DEMUXER, H264_DECODER) += fate-tee-muxer-h264
+
+fate-tee-muxer-ignorefail: CMD = ./ffmpeg  -f lavfi -i "testsrc=s=640x480" -f lavfi -i "sine"\
+			         -t 1 -map 0:v -map 1:a -c:v copy -c:a copy -flags +bitexact -fflags +bitexact -f tee\
+				 "[f=framecrc]$(SRC_PATH)/tests/data/fate/tee-muxer-ignorefail|[f=framecrc:onfail=ignore]$(SRC_PATH)/dev/full"
+FATE-TEE-MUXER-$(CONFIG_TEE_MUXER) += fate-tee-muxer-ignorefail
+
+fate-tee-muxer-tstsrc: CMD = ./ffmpeg  -f lavfi -i "testsrc=s=640x480" -f lavfi -i "sine"\
+                             -t 1 -map 0:v -map 1:a -c:v copy -c:a copy -flags +bitexact -fflags +bitexact -f tee\
+			     "[f=framecrc]$(SRC_PATH)/tests/data/fate/tee-muxer-tstsrc-copy|[f=framecrc:select=1]$(SRC_PATH)/tests/data/fate/tee-muxer-tstsrc-audio"
+fate-tee-muxer-tstsrc: CMP = mdiff
+FATE-TEE-MUXER-$(CONFIG_TEE_MUXER) += fate-tee-muxer-tstsrc
+
+FATE_SAMPLES_FFMPEG += $(FATE-SAMPLES-TEE-MUXER-yes)
+FATE_FFMPEG += $(FATE-TEE-MUXER-yes)
+
+fate-tee-muxer: $(FATE-TEE-MUXER-yes) $(FATE-SAMPLES-TEE-MUXER-yes)
diff --git a/tests/ref/fate/tee-muxer-h264 b/tests/ref/fate/tee-muxer-h264
new file mode 100644
index 0000000..2a99a6b
--- /dev/null
+++ b/tests/ref/fate/tee-muxer-h264
@@ -0,0 +1,2 @@
+tee-muxer-h264-copy  tee-muxer-h264-copy
+tee-muxer-h264-audio tee-muxer-h264-audio
\ No newline at end of file
diff --git a/tests/ref/fate/tee-muxer-h264-audio b/tests/ref/fate/tee-muxer-h264-audio
new file mode 100644
index 0000000..0b42d11
--- /dev/null
+++ b/tests/ref/fate/tee-muxer-h264-audio
@@ -0,0 +1,30 @@
+#extradata 0:        2, 0x00b200a1
+#tb 0: 1/1000
+#media_type 0: audio
+#codec_id 0: aac
+#sample_rate 0: 48000
+#channel_layout 0: 3
+0,         42,         42,       21,        6, 0x027e00e8
+0,         63,         63,       21,        6, 0x027e00e8
+0,         84,         84,       21,        6, 0x027e00e8
+0,        105,        105,       21,        6, 0x027e00e8
+0,        127,        127,       21,        6, 0x027e00e8
+0,        148,        148,       21,       24, 0x886f0c1f
+0,        169,        169,       21,      550, 0xf863059c
+0,        190,        190,       22,      596, 0x32d414c1
+0,        213,        213,       21,      247, 0x2d0776c9
+0,        234,        234,       21,      264, 0xf04a7b44
+0,        255,        255,       21,      251, 0xc7628539
+0,        276,        276,       22,      243, 0x99ef768b
+0,        298,        298,       21,      257, 0x233f7ccc
+0,        319,        319,       21,      264, 0x7d9f7bd9
+0,        340,        340,       21,      298, 0x51478f98
+0,        361,        361,       22,      323, 0x419d9938
+0,        383,        383,       21,      309, 0x6219980c
+0,        404,        404,       21,      325, 0x3fb3976f
+0,        425,        425,       21,      325, 0xcd7a9fd6
+0,        446,        446,       22,      359, 0x6edeb91c
+0,        468,        468,       21,      333, 0xb8999fb7
+0,        489,        489,       21,      317, 0xf2589e1a
+0,        510,        510,       21,      319, 0x82ed9572
+0,        531,        531,       22,      473, 0xea54e696
diff --git a/tests/ref/fate/tee-muxer-h264-copy b/tests/ref/fate/tee-muxer-h264-copy
new file mode 100644
index 0000000..0e356ec
--- /dev/null
+++ b/tests/ref/fate/tee-muxer-h264-copy
@@ -0,0 +1,47 @@
+#extradata 0:       93, 0xc2a32e14
+#extradata 1:        2, 0x00b200a1
+#tb 0: 1/1000
+#media_type 0: video
+#codec_id 0: h264
+#dimensions 0: 1280x718
+#sar 0: 1/1
+#tb 1: 1/1000
+#media_type 1: audio
+#codec_id 1: aac
+#sample_rate 1: 48000
+#channel_layout 1: 3
+0,          0,         42,       41,     2969, 0xa7016742
+0,         42,         84,       41,      135, 0x33af1a9e, F=0x0
+1,         42,         42,       21,        6, 0x027e00e8
+1,         63,         63,       21,        6, 0x027e00e8
+0,         84,        125,       41,     9196, 0x24d8439f
+1,         84,         84,       21,        6, 0x027e00e8
+1,        105,        105,       21,        6, 0x027e00e8
+0,        125,        167,       41,     4926, 0xd7e2e492, F=0x0
+1,        127,        127,       21,        6, 0x027e00e8
+1,        148,        148,       21,       24, 0x886f0c1f
+0,        167,        209,       41,    11069, 0x44839c66
+1,        169,        169,       21,      550, 0xf863059c
+1,        190,        190,       22,      596, 0x32d414c1
+0,        209,        292,       41,     6143, 0xc25343dd, F=0x0
+1,        213,        213,       21,      247, 0x2d0776c9
+1,        234,        234,       21,      264, 0xf04a7b44
+0,        251,        251,       41,     4197, 0x3b9f74ad, F=0x0
+1,        255,        255,       21,      251, 0xc7628539
+1,        276,        276,       22,      243, 0x99ef768b
+0,        292,        376,       41,    17595, 0x1e502128, F=0x0
+1,        298,        298,       21,      257, 0x233f7ccc
+1,        319,        319,       21,      264, 0x7d9f7bd9
+0,        334,        334,       41,      741, 0xe6b94afc, F=0x0
+1,        340,        340,       21,      298, 0x51478f98
+1,        361,        361,       22,      323, 0x419d9938
+0,        376,        459,       41,    16138, 0xba72f2fe, F=0x0
+1,        383,        383,       21,      309, 0x6219980c
+1,        404,        404,       21,      325, 0x3fb3976f
+0,        417,        417,       41,      322, 0xd6bf790f, F=0x0
+1,        425,        425,       21,      325, 0xcd7a9fd6
+1,        446,        446,       22,      359, 0x6edeb91c
+1,        468,        468,       21,      333, 0xb8999fb7
+1,        489,        489,       21,      317, 0xf2589e1a
+1,        510,        510,       21,      319, 0x82ed9572
+1,        531,        531,       22,      473, 0xea54e696
diff --git a/tests/ref/fate/tee-muxer-ignorefail b/tests/ref/fate/tee-muxer-ignorefail
new file mode 100644
index 0000000..2c57803
--- /dev/null
+++ b/tests/ref/fate/tee-muxer-ignorefail
@@ -0,0 +1,79 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 640x480
+#sar 0: 1/1
+#tb 1: 1/44100
+#media_type 1: audio
+#codec_id 1: pcm_s16le
+#sample_rate 1: 44100
+#channel_layout 1: 4
+0,          0,          0,        1,   921600, 0xbac50a6a
+1,          0,          0,     1024,     2048, 0x1ee8f45a
+1,       1024,       1024,     1024,     2048, 0x273ef6ee
+0,          1,          1,        1,   921600, 0x9518a5c6
+1,       2048,       2048,     1024,     2048, 0x0a5f0111
+1,       3072,       3072,     1024,     2048, 0x51be06b8
+0,          2,          2,        1,   921600, 0x6d772b45
+1,       4096,       4096,     1024,     2048, 0x71a1ffcb
+1,       5120,       5120,     1024,     2048, 0x7f64f50f
+0,          3,          3,        1,   921600, 0xd0a99ac9
+1,       6144,       6144,     1024,     2048, 0x70a8fa17
+0,          4,          4,        1,   921600, 0xef2bf424
+1,       7168,       7168,     1024,     2048, 0x0dad072a
+1,       8192,       8192,     1024,     2048, 0x5e810c51
+0,          5,          5,        1,   921600, 0x575c3d5a
+1,       9216,       9216,     1024,     2048, 0xbe5bf462
+1,      10240,      10240,     1024,     2048, 0xbcd9faeb
+0,          6,          6,        1,   921600, 0xa123687b
+1,      11264,      11264,     1024,     2048, 0x0d5bfe9c
+1,      12288,      12288,     1024,     2048, 0x97d80297
+0,          7,          7,        1,   921600, 0x30667ded
+1,      13312,      13312,     1024,     2048, 0xba0f0894
+0,          8,          8,        1,   921600, 0x9c507cf9
+1,      14336,      14336,     1024,     2048, 0xcc22f291
+1,      15360,      15360,     1024,     2048, 0x11a9fa03
+0,          9,          9,        1,   921600, 0x5a8762c3
+1,      16384,      16384,     1024,     2048, 0x9a920378
+1,      17408,      17408,     1024,     2048, 0x901b0525
+0,         10,         10,        1,   921600, 0x5f89340f
+1,      18432,      18432,     1024,     2048, 0x74b2003f
+0,         11,         11,        1,   921600, 0x1f27eee6
+1,      19456,      19456,     1024,     2048, 0xa20ef3ed
+1,      20480,      20480,     1024,     2048, 0x44cef9de
+0,         12,         12,        1,   921600, 0x2bcd941d
+1,      21504,      21504,     1024,     2048, 0x4b2e039b
+1,      22528,      22528,     1024,     2048, 0x198509a1
+0,         13,         13,        1,   921600, 0x2ff6168a
+1,      23552,      23552,     1024,     2048, 0xcab6f9e5
+1,      24576,      24576,     1024,     2048, 0x67f8f608
+0,         14,         14,        1,   921600, 0x46ac8d78
+1,      25600,      25600,     1024,     2048, 0x8d7f03fa
+0,         15,         15,        1,   921600, 0x7d31eef4
+1,      26624,      26624,     1024,     2048, 0x3e1e0566
+1,      27648,      27648,     1024,     2048, 0x2cfe0308
+0,         16,         16,        1,   921600, 0x30794ac7
+1,      28672,      28672,     1024,     2048, 0x1ceaf702
+1,      29696,      29696,     1024,     2048, 0x38a9f3d1
+0,         17,         17,        1,   921600, 0xaa819657
+1,      30720,      30720,     1024,     2048, 0x6c3306b7
+1,      31744,      31744,     1024,     2048, 0x600f0579
+0,         18,         18,        1,   921600, 0x3d8ef1de
+1,      32768,      32768,     1024,     2048, 0x3e5afa28
+0,         19,         19,        1,   921600, 0xd6f94db1
+1,      33792,      33792,     1024,     2048, 0x053ff47a
+1,      34816,      34816,     1024,     2048, 0x0d28fed9
+0,         20,         20,        1,   921600, 0x8a9da938
+1,      35840,      35840,     1024,     2048, 0x279805cc
+1,      36864,      36864,     1024,     2048, 0xb16a0a12
+0,         21,         21,        1,   921600, 0xb74df48b
+1,      37888,      37888,     1024,     2048, 0xb45af340
+0,         22,         22,        1,   921600, 0xb3fc509b
+1,      38912,      38912,     1024,     2048, 0x1834f972
+1,      39936,      39936,     1024,     2048, 0xb5d206ae
+0,         23,         23,        1,   921600, 0xecc1ac22
+1,      40960,      40960,     1024,     2048, 0xc5760375
+1,      41984,      41984,     1024,     2048, 0x503800ce
+0,         24,         24,        1,   921600, 0x3e6207f5
+1,      43008,      43008,     1024,     2048, 0xa3bbf4af
+1,      44032,      44032,     1024,     2048, 0x9012f9d2
diff --git a/tests/ref/fate/tee-muxer-tstsrc b/tests/ref/fate/tee-muxer-tstsrc
new file mode 100644
index 0000000..c1d44a3
--- /dev/null
+++ b/tests/ref/fate/tee-muxer-tstsrc
@@ -0,0 +1,2 @@
+tee-muxer-ignorefail   tee-muxer-tstsrc-copy
+tee-muxer-tstsrc-audio tee-muxer-tstsrc-audio
diff --git a/tests/ref/fate/tee-muxer-tstsrc-audio b/tests/ref/fate/tee-muxer-tstsrc-audio
new file mode 100644
index 0000000..720952d
--- /dev/null
+++ b/tests/ref/fate/tee-muxer-tstsrc-audio
@@ -0,0 +1,49 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout 0: 4
+0,          0,          0,     1024,     2048, 0x1ee8f45a
+0,       1024,       1024,     1024,     2048, 0x273ef6ee
+0,       2048,       2048,     1024,     2048, 0x0a5f0111
+0,       3072,       3072,     1024,     2048, 0x51be06b8
+0,       4096,       4096,     1024,     2048, 0x71a1ffcb
+0,       5120,       5120,     1024,     2048, 0x7f64f50f
+0,       6144,       6144,     1024,     2048, 0x70a8fa17
+0,       7168,       7168,     1024,     2048, 0x0dad072a
+0,       8192,       8192,     1024,     2048, 0x5e810c51
+0,       9216,       9216,     1024,     2048, 0xbe5bf462
+0,      10240,      10240,     1024,     2048, 0xbcd9faeb
+0,      11264,      11264,     1024,     2048, 0x0d5bfe9c
+0,      12288,      12288,     1024,     2048, 0x97d80297
+0,      13312,      13312,     1024,     2048, 0xba0f0894
+0,      14336,      14336,     1024,     2048, 0xcc22f291
+0,      15360,      15360,     1024,     2048, 0x11a9fa03
+0,      16384,      16384,     1024,     2048, 0x9a920378
+0,      17408,      17408,     1024,     2048, 0x901b0525
+0,      18432,      18432,     1024,     2048, 0x74b2003f
+0,      19456,      19456,     1024,     2048, 0xa20ef3ed
+0,      20480,      20480,     1024,     2048, 0x44cef9de
+0,      21504,      21504,     1024,     2048, 0x4b2e039b
+0,      22528,      22528,     1024,     2048, 0x198509a1
+0,      23552,      23552,     1024,     2048, 0xcab6f9e5
+0,      24576,      24576,     1024,     2048, 0x67f8f608
+0,      25600,      25600,     1024,     2048, 0x8d7f03fa
+0,      26624,      26624,     1024,     2048, 0x3e1e0566
+0,      27648,      27648,     1024,     2048, 0x2cfe0308
+0,      28672,      28672,     1024,     2048, 0x1ceaf702
+0,      29696,      29696,     1024,     2048, 0x38a9f3d1
+0,      30720,      30720,     1024,     2048, 0x6c3306b7
+0,      31744,      31744,     1024,     2048, 0x600f0579
+0,      32768,      32768,     1024,     2048, 0x3e5afa28
+0,      33792,      33792,     1024,     2048, 0x053ff47a
+0,      34816,      34816,     1024,     2048, 0x0d28fed9
+0,      35840,      35840,     1024,     2048, 0x279805cc
+0,      36864,      36864,     1024,     2048, 0xb16a0a12
+0,      37888,      37888,     1024,     2048, 0xb45af340
+0,      38912,      38912,     1024,     2048, 0x1834f972
+0,      39936,      39936,     1024,     2048, 0xb5d206ae
+0,      40960,      40960,     1024,     2048, 0xc5760375
+0,      41984,      41984,     1024,     2048, 0x503800ce
+0,      43008,      43008,     1024,     2048, 0xa3bbf4af
+0,      44032,      44032,     1024,     2048, 0x9012f9d2
