Search code examples
iosvideoffmpegvideo-streaminglive-streaming

Video encoding in ios


So I already know there are existing questions on StackOverflow about streaming live video on ios devices to a server but I'm going to ask about the encoding portion.

I'm a bit lost on which software encoding services are available to encode the raw (live) video footage from an ios device to send to a server like AWS. After using AVCam to capture videos, would I use something like ffmpeg to encode the raw video on the fly and then send the encoded video to the server using HTTP or RTSP? Or do I have the concepts wrong?


Solution

  • The video is already encoded when it is stored on the iOS device - encoding is just a way of digitally representing the video, in most cases capturing some values to represent the color and brightness etc of each pixel in each frame of the video.

    Most encoding also includes techniques to compress the video to conserve space. These techniques include using some of the frames as a reference for following frames (and in come cases preceding frames). For example the first frame might be a reference frame (commonly called an I frame) and for the following five frames, instead of storing all the pixel data, only pixels which have changes are stored. It is easy to understand how this might save a lot of storage, particularly for any scenes where there is little movement or change in the scenes.

    As a general rule, you lose some quality when you compress and the more you compress the more quality you lose. On iOS you can specify the quality level you want when you are setting up the video capture - see 'Configuring a Session' in the line below:

    Unless you need to store locally in a different quality level than you are sending to the server, you should just record in the quality level you want and avoid having to compress on the phone as it is quite a bit of work for the phone to do, if you can avoid it. if you do want to have a higher quality stored on the phone and lower quality (to speed up transmission or save bandwidth) to send to the server, take a look at this answer: