简体   繁体   English

使用.m3u8和.ts文件与iPhone作为服务器的直播

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

I am trying to accomplish a task to live stream from iPhone camera. 我正在尝试完成从iPhone相机直播的任务。 I have done some research and found that i can use .m3u8 files for streaming live video with should contain . 我做了一些研究,发现我可以使用.m3u8文件播放实时视频,应该包含。 ts(Mpeg-2) files . ts(Mpeg-2)文件。

Now the file which i have on my iPhone is .mp4 file and it does not work with .m3u8, so i figured out i will have to convert .mp4 to .ts for that , but i have not succeeded in doing so. 现在我在我的iPhone上的文件是.mp4文件,它不能与.m3u8一起使用,所以我想出来我必须将.mp4转换为.ts ,但我还没有成功。

I found that it is possible to convert video ffmpeg lib as mentioned in this article here . 我发现可以转换视频ffmpeg lib,本文所述 I have successfully imported ffmpeg library but not able figure out how can i use it to convert a video as i am using this for first time. 我已成功导入ffmpeg库但无法弄清楚如何使用它来转换视频,因为我是第一次使用它。

One another thing apple documentation says 苹果文档说的另一件事

There are a number of hardware and software encoders that can create MPEG-2 transport streams carrying MPEG-4 video and AAC audio in real time. 有许多硬件和软件编码器可以实时创建携带MPEG-4视频和AAC音频的MPEG-2传输流。

What is being said here? 在这说什么? is there any other way i can use .mp4 files for live streaming without converting them from iOS? 有没有其他方法我可以使用.mp4文件进行直播,而无需从iOS转换它们?

Let me know if i am not clear, i can provide more information .Any suggestion is appreciated. 如果我不清楚,请告诉我,我可以提供更多信息。感谢任何建议。 I would like to know am i on a right path here? 我想知道我在正确的道路上吗?

EDIT 编辑

I am adding more info to my question, so basically what i am asking is , we can convert .mp4 video to .ts using following command 我正在为我的问题添加更多信息,所以基本上我要问的是,我们可以使用以下命令将.mp4视频转换为.ts

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 do what this command does in iOS. 我如何使用ffmpeg库来执行此命令在iOS中执行的操作。

You can look at ffmpeg.c to see what the ffmpeg uses from the ffmpeg libraries. 您可以查看ffmpeg.c以查看ffmpeg从ffmpeg库中使用的内容。 It's a pretty complicated file, however. 然而,这是一个非常复杂的文件。 You may want to rename main() and compile it to an object, then you could call the new ffmpeg_main() function from your code. 您可能想要重命名main()并将其编译为对象,然后您可以从代码中调用新的ffmpeg_main()函数。

Apple device work on HLS only and you need to convert the media files from mp4 to ts along with the metadata file as m3u8. Apple设备仅适用于HLS,您需要将媒体文件从mp4转换为ts,并将元数据文件转换为m3u8。 You can use the streamers like gstreamer etc to stream you mp4 to HLS format or the other way is to trans-code on fly which is very slow. 您可以使用gstreamer之类的拖缆将mp4转换为HLS格式,或者另一种方法是在飞行中进行转码,这非常慢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM