MP4, MOV and 3GP all contain some important metadata at the end of the file. This stems from ages predating streaming and makes these formats by default unfit for it.
The solution is to store that so called moov atomat the beginning of the file. This means you must preprocess iPhone videos in order to stream them.
With ffmpeg e.g. via FFmpegKit the option is -movflags faststart
.
With AVAssetWriter/AVAssetExportSession it's the flag shouldOptimizeForNetworkUse
(via).
These need to write to a file on device though, maybe you can work around that with a named pipe read by Alamofire.
VLC and iOS separately transfer the moov atom to make sense of the rest. If you could apply this strategy to ffmpeg you'd only need to find the moov atom on the phone. But there were no examples to find of ffmpeg setup this way.
Your server code seems fine, probably only needs the -movflags faststart
as output option there, too. For testing upload an MKV or WEBM file which ffmpeg can read streamed out of the box.