iOS stream live h.264 video

h.264, ios, live, streaming

Solution

You cannot play elementary h.264 on iOS. Your workaround can be to wrap it in a mp4 or ts stream before playing [http pd download or hls]. But unless you compile something else (like ffmpeg) onto the device you will not be able to play raw h.264

Problem

I have a video stream with mime type video/h264 that streams live h.264 video from a security camera. I am trying to stream this real time and decode the h.264 frames (preferably hardware decode) and display them in a view. I have looked extensively for libraries or frameworks to support this but am not exactly sure which is the right approach. I have looked a little bit at the AVFoundation but not sure how to handle the video/h264 stream. Should I be grabbing each frame (I frame / P frame) from the stream and passing it the AVAssetReader? Any direction / sample code / library references would be extremely helpful! ``` HTTP/1.1 200 OK Date: {date} Connection: keep-alive Cache-Control: no-cache, no-store Expires: -1 Content-Type: multipart/x-mixed-replace;boundary=myboundary Set-Cookie: stream={stream-id}; version=1 --myboundary Content-Type: video/h264 Sync-Point: "yes" or "no" Pre-roll: "yes" or "no" Media-Start: "invalid" or {mediastart} Media-End: "invalid" or {mediaend} Stream-Start: "invalid" or {stream start time} Stream-End: "invalid" or {stream end time} Content-Length: {content-length} X-Date: {x-date} {image} ```

Original source