Live Stream using .m3u8 and .ts files with iPhone as server

I am trying to do a task of live streaming from an iPhone camera. I did some research and found that I can use files .m3u8

for live streaming video, which should contain the files ts(Mpeg-2)


Now the file I have on my iPhone is a .mp4

file and it doesn't work with .m3u8, so I figured I would have to convert to .mp4

in .ts

order to do this, but I failed in doing so.

I found that it is possible to convert ffmpeg lib video as mentioned in this article here . I imported the library successfully ffmpeg

, but couldn't figure out how I can use it to convert the video as I am using this for the first time.

One more thing apple documentation says

There are a number of hardware and software encoders that can create MPEG-2 Transport Streams with MPEG-4 video and AAC audio in real time.

What does it say here? is there any other way i can use .mp4 files for live streaming without converting them from iOS?

Let me know if I don't understand, I can provide more information. Any suggestion is greatly appreciated. I would like to know if I am on the right track here?


I am adding more information to my question, so basically what I'm asking is, we can convert .mp4 video to .ts using the following command

ffmpeg -i file.mp4 -acodec libfaac -vcodec libx264 -an -map 0 -f segment -segment_time 10 -segment_list test.m3u8 -segment_format mpegts -vbsf h264_mp4toannexb -flags -global_header stream%05d.ts


How can I use ffmpeg library to execute this command in iOS.


source to share

2 answers

You can take a look at ffmpeg.c to see what ffmpeg uses from the ffmpeg libraries. However, this is a rather complex file. You may want to rename main () and compile it for an object, then you can call the new ffmpeg_main () function from your code.



Apple device only works with HLS and you need to convert media from mp4 to ts along with metadata file to m3u8. You can use streamers like gstreamer etc. to stream your mp4 to HLS format, otherwise you have to recode on the fly, which is very slow.



All Articles