Maybe you can check the source code of my streaming app:
https://forum.speeddemosarchive.com/post/kumari_alpha_1.html
Check in common/rtmp_broadcaster.cpp. It is too long to post here. The code should be the same for iOS. You will only have to modify how the captured frame data is input into ffmpeg. Since you already have the frame data, this should not be too difficult.