IOS Fast Integration Ijkplayer video streaming and recording framework

Source: Internet
Author: User

Recently due to the change in demand, the project to the original simplest native live broadcast framework into the B station open source Ijkplayer framework, the following specific process to summarize the whole process is relatively simple, it is important to understand the process, after integration, the video user experience is much better than Apple native. The demo git address will be posted at the end, so you can quickly add the framework to your project with just a few simple actions.

Put the GitHub address of the B station open source Ijkplayer first Https://github.com/Bilibili/ijkplayer
Unused classmates, please go to get help understanding the whole video frame principle.

* * Why change the video broadcast in the original project, recording frame? **

First of all, let me tell you why the original live and video frames are modified within our project, and this process can be reflected in the Ijkplayer comparison of the advantages of iOS native.

1. The original soundtrack we used was the use of MPMoviePlayerController, which Apple officials have prompted to use Avplayerviewcontroller instead, Although MPMoviePlayerController can be used for the time being, it may be problematic in the near future.
2. Compare LIVE: The first indicator of live broadcast is the delay problem, Apple native Live broadcast protocol only support HLS protocol, and Ijkplayer not only support HLS, but also support rtmp protocol, the disadvantage of HSL protocol is a headache delay problem, the protocol will cut the video into a segment of m3u8 video clips, The latency is generally about 10 seconds, and the RTMP protocol is very slow, and the smoothness of the video improves a lot from the end of the modification. This is one of the root causes of changes to the live broadcast framework.
3. Compare the recording stream: if the video stream stored in the cloud is playing simultaneously, there are some unavoidable problems, that is, the supported video encoding format is very limited: H. MPEG-4, extension (compressed format):. mp4,. mov,. M4V,. m2v,. 3gp,. 3g2, etc. This support requires a high level of operational operation, with fewer formats supported. Ijkplayer not only includes all the formats that the native can support, but the mainstream video format can be fully supported.
4. Compare user interaction: MPMoviePlayerController Some gestures for custom styles and user interaction are very limited, and ijkplayer you can almost customize all the interactions you can think of, and the mainstream live streaming app is in use.

In contrast to the above reasons, we have made further upgrades in the project, and the need to use Ijkplayer is very urgent.

* * Main CODE related * *

The specific demo will post a link below, which shows only the most important steps required.

1. After downloading the demo, because the Ijk framework package is relatively large, so it is not uploaded with the project, it is necessary to first download the Ijk Framework zip package in GitHub address details, import the project, and configure the path.

In fact, the process of playing out Ijk framework package is a very good understanding process, because there are a lot of packaging process, here to post a more detailed for everyone to reference
Point here, this process is more detailed

2. Several files in the import


Paste_image.png

3. Initialize key code within the project, write to run

    Create a parent view of a video player to change fullscreen and zoom out _headplayerview = [[UIView Alloc]initwithframe:CGRectMake (0,0, [UIScreen Mainscreen].bounds.size.width, [UIScreen mainscreen].bounds.size.width*videotempprogress)]; [Self.view Addsubview:_headplayerview];Test addressRTMP Live Hong Kong TV test address RTMP://LIVE.HKSTV.HK.LXDNS.COM/LIVE/HKSVideo playback Stream http://hc.yinyuetai.com/uploads/videos/common/E49E014999C93F5A88EA01B2B48161CE.flv?sc=fc5276d37b6cd89c &br=775&vid=2178416&aid=2650&area=other&vst=3//The model can be arbitrarily set to pass in what you want to customize Xyvideomodel *model = [[Xyvideomodel alloc]init]; model.url = [nsurl urlwithstring:@ "Http://hc.yinyuetai.com/uploads/videos/common/E49E014999C93F5A88EA01B2B48161CE.flv?sc=fc5276d37b6cd89c&br =775&vid=2178416&aid=2650&area=other&vst=3 "]; Model.name = @ "Test title Test title Test title "; model.coverimg = @ "Coverimg.jpeg"; //Create video playback controls self.playerview = [[Lmvideoplayerview Alloc]initwithmodel:model]; //Follow lmvideoplayerviewdelegate to achieve exit full screen and zoom in agent self.playerView.delegate = self ; [_headplayerview addsubview:Self.playerview];          
#pragma Mark XyvideoplayerviewdelegateFull-screen button proxy Method-(void) Fullscreenwithplayerview: (Lmvideoplayerview *) videoplayerview{Click to enlarge rotation and return to zoom out methodif (Self.playerView.isRotate) {[UIView animatewithduration:0.3 animations:^{_headplayerview.transform =Cgaffinetransformrotate (_headplayerview.transform, m_pi_2); _headplayerview.frame =CGRectMake (0,0, [UIScreen Mainscreen].bounds.size.width, [UIScreen mainscreen].bounds.size.height);Self.playerView.frame = _headplayerview.bounds; }]; }else{[uiview animatewithduration: 0.3 animations:^{_headplayerview.transform =  cgaffinetransformidentity; _headplayerview.frame = cgrectmake (0, 0, [uiscreen mainscreen].bounds.size.width, [uiscreen mainscreen].bounds.size.width*videotempprogress); self.playerview.frame = _headplayerview.bounds;}]; }}//Back button Proxy Method-(void) backtobeforevc{ if (! Self.playerView.isRotate) {[self.navigationcontroller Popviewcontrolleranimated:yes]; }}

* * GitHub Demo Address * *

Demo address, Welcome to star

If you have any questions or questions about Ijk, you can always leave a message or communicate in private messages.



Dead Han Leesim
Links: https://www.jianshu.com/p/3c109b2c5ba9
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

IOS Fast Integration Ijkplayer video streaming and recording framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.