From 3fb5b921a1e9f080329479118c395db0744c5609 Mon Sep 17 00:00:00 2001 From: keicotu Date: Mon, 12 Sep 2016 18:15:48 +0800 Subject: [PATCH] [What] Duplicate AUDs are added when the input H.264 already has AUD. And the output HLS stream or the ts files can't be played normal in Safari/QuickTime player. (the frame display becomes incorrect.) [Why] The size of AUD in the sample are 3 and "nalu_size != 2" is always true, so AUDs are added. [How] Remove the nalu_size checking and only check unit type. --- Source/C++/Core/Ap4Mpeg2Ts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/C++/Core/Ap4Mpeg2Ts.cpp b/Source/C++/Core/Ap4Mpeg2Ts.cpp index d21b70e00..6529b5119 100644 --- a/Source/C++/Core/Ap4Mpeg2Ts.cpp +++ b/Source/C++/Core/Ap4Mpeg2Ts.cpp @@ -660,7 +660,7 @@ AP4_Mpeg2TsVideoSampleStream::WriteSample(AP4_Sample& sample, // check if we need to add a delimiter before the NALU if (nalu_count == 0 && sample_description->GetType() == AP4_SampleDescription::TYPE_AVC) { - if (nalu_size != 2 || (data[0] & 0x1F) != AP4_AVC_NAL_UNIT_TYPE_ACCESS_UNIT_DELIMITER) { + if ((data[0] & 0x1F) != AP4_AVC_NAL_UNIT_TYPE_ACCESS_UNIT_DELIMITER) { // the first NAL unit is not an Access Unit Delimiter, we need to add one unsigned char delimiter[6]; delimiter[0] = 0;