Set AVAssetWriterInput's AVVideoCompressionPropertiesKey as follows:
AVVideoCompressionPropertiesKey = {
AllowFrameReordering = 0;
AverageBitRate = 30000000;
ProfileLevel = "H264_Main_AutoLevel";
};
The exported video has B frame and level is 60, it is not supported by Photo app.