Talking about the n solution of iOS video playback

Source: Internet
Author: User

JaneRegisterLoginAdd concernauthor Maru 2016.03.22 20:46* Wrote 4349 words, was paid attention by 135 people, gained 207 likesWord 1621Read 2895 comments on 159 likes
Header.jpeg Preface

Although I disagree with you, I'll defend your right to speak to the!--Voltaire.

For a long time did not write the article, this topic in fact I want to write a very early, because from my first complete app project, almost every app has video playback needs, but I did not dare to start writing, because I think about video playback of the underlying technology implementation I still smattering. But still wrote this article, I hope that the great God can not hesitate to enlighten me, but also hope and I like the progress of the people can have some benefits, less detours, after reading this article can choose the most suitable for their own technology implementation program.

Bronze Age

Remember when you first learned iOS? At that time, it was amazing to have a few simple pieces of code to do all sorts of awesome functions. Video playback is also the case, open a few old iOS textbooks, you can see it in the directory. Yes, it is:

<MediaPlayer/MediaPlayer.h>

In the MediaPlayer framework, if you are lazy enough, you can use Mpmovieplayerviewcontroller to complete your playback function with three lines of code. However, look up to the big video app, and their playback interface is like this:


UC player. jpg

Look down at your player, but that's it:


Artistic requirements, do not take it seriously. png

Mom eggs, good low ah have wood, is can endure who cannot endure! Fortunately Apple has also provided us with a class MPMoviePlayerController, which allows us to customize the UI of the player, Recommended here is a domestic engineer open source based on the MPMoviePlayerController player Krvideoplayer, I believe that the majority of small partners needs can be solved perfectly.

Industrial Age

The wheels of history roll forward, never cease,

However MPMoviePlayerController custom players are not perfect:

    1. MPMoviePlayerController was abandoned by Apple in IOS9;
    2. When we need to deeply customize the player's needs, MPMoviePlayerController is not enough, such as the author before a voice-over software, need to play only video footage, without the need for video sound, but also need to turn on audio recording, And another audio player to play the background sound. This time, MPMoviePlayerController cried.

Given the limitations of <MediaPlayer/MediaPlayer.h>, the new framework emerges--avkit.

Avkit is a high-level object that is built on avfoundation to solve video playback. From the Avfoundation Programming Guide we can see a technology stack like this:


Screen shot 2016-03-22 pm 6.45.36.png

If someone remembers Avfoundation just out of that year's WWDC, must be impressed with the performance of Avfoundation, while playing 100 videos without the slightest! In the author's use process also verified this point, whether for the local video or network online on-demand, avfoundation performance is exceptionally excellent.

Let's look at the structure of Avkit first:


Avkit structure. png

As this article is only a "shopping guide" role, and about the avkit of related article documents a plethora therefore no longer introduced. Several third-party video frameworks based on Avkit are recommended below:

    1. Vkvideoplayer
    2. Almovieplayercontroller
    3. Pbjvideoplayer
Post-Industrial era

However, there will always be one, however, Avkit is not flawless, when we need to play some very standard video (such as RMVB), Avkit can only feel powerless.

Believing that Mac users are familiar with a VLC player, this player behaves exceptionally well on Mac, supporting formats that cover almost all formats (that's it!). )。 Yes, it's the creator--videolan, the open source of a video playing a game frame mobilevlckit!

Let's start by looking at the formats it supports:

. RMVB . asf . avi . dv . flv. gxf . m1v . m2v . m2ts. mkv . m OV . MP2 . mp4 . mpeg1 . MPEG2 . MPEG4 . mpg. mts . MXF. ogg . OGM C13>.ps . ts . VOB . A52 . AAC. AC3 . m4a. m4p . M Ka . mod . MP1 . MP2 . mp3 *.ogg.

Isn't it very exciting? Then let's get started!

1. Framework Compilation

Before show you code, we always need to have its library first? The official gave a detailed tutorial, English is not good? FQ speed is not good? Never mind! There is a compiled VLC framework, download it!

Mobilevlckit Static Library Download link

2. Project compilation

Mobilevlckit's static library is very large, decompression down after almost 600+mb, but only a few m after compiling, so rest assured that use it.

    1. Linked frameworks and libraries are added to download the completed Mobilevlckit;

    2. To add a dependent framework, Mobilevlckit relies on the following framework:


Screen shot 2016-03-22 pm 8.11.05.png
    1. Modify the compilation options, because the framework is written by C + +, so we need to change the relevant compilation options;

6df02a9c-7e7a-422f-bf69-41f381f2659b.png
    1. Modify the framework Search Paths, otherwise the project cannot find the frame;

Cdfc9f51-d803-4376-a698-f29bdb542576.png

PS: "Std::ios_base::init::~init ()", referenced from
This compilation problem occurs, it is necessary to add libstdc++.dylib and libstdc++.6.dylib (for 6.1 use, XCODE5 after the default complier can also be compiled through)

Ok! Good surprise, CMD + B compiled successfully!

In order to offer my own. Based on the Mobilevlckit written by the player: Mrvlcplayer, originally I just Want to do a demo, but do think to make a framework, there are many features are not perfect, but as a demo should be enough.


Mrvlcplayer.gif Information Age

Of course, if you know some video decoding more professional knowledge, you can also use FFmpeg and live555, so you can learn more about the underlying video technology. Of course, Bo Master is now also learning this knowledge, this is only recommended to everyone, by the way quietly said, in fact, Mobilevlckit is based on the development of FFmpeg two times.

Stone Age PostScript

No matter how clever and obscure the technology is, the ultimate goal is to serve the people. Human evolution from the Stone Age to now, the hands of the tools for a stubble after another stubble, blindly dazzling technology does not make any sense, choose the right tool for their path. I believe that more than 90% of the demand, in this article before the information Age can be resolved, the choice of the right in your hands. Well, let's not say, I'm going to knock the female ape next to me into the cave, we'll see you next time.

    recommended Expand ReadingCopyright belongs to the author

    If you feel that my article is useful to you, please feel free to make a reward. Your support will encourage me to continue to create!

    CNY Rewards supportlike159share to WeiboShare toMore SharexLike the user
    • Xi Shi 2016.05.25 00:03
    • M_lee2016.05.20 17:59
    • Westwood Grapefruit 2016.05.20 11:20
    • Accompany rain 2016.05.19 17:34
    • Night Red Snow 2016.05.19 12:01
    • Recker2016.05.17 01:56
    • Mosaics2016.05.16 23:07
    • , stroll vicissitudes 2016.05.16 21:06
    • Alfalfa Ghost Fairy 2016.05.16 16:07
    • Horse ye 2016.05.16 00:24
    • Tosimple2016.05.15 18:11
    • Give my heart warm 2016.05.15 16:31
    • Pingsheng 2016.05.15 08:30
    • Bigbylong2016.05.14 17:50
    • TATE_ZWT2016.05.13 21:46
    43 reviews Add a new comment by time sequence • Reverse chronological • Sort by preference

    Metamay

    2/F · 2016.03.22 22:28

    Want to ask, about the speed of the video, smooth, high-definition how these mode switch is implemented, is to request three different video links?

    enjoyed (0)Reply

    Maru: @MetaMay really do have this approach, such as the Super-helper app is to provide three links to distinguish between clarity, there is also through the transfer server to achieve the definition of the switch.

    Reply2016.03.23 20:28Add a new reply

    Lovecode

    3/F · 2016.03.23 20:02

    Good,thanks.

    enjoyed (0)Reply

    Maru: @LoveCode Thank you

    Reply2016.03.23 20:28Add a new reply

    Kayou

    4/F · 2016.03.23 20:52

    Not better

    enjoyed (0)Reply

    Walk with Great Lee

    5/F · 2016.03.23 21:41

    enjoyed (0)Reply

    Teckht's Daddy

    6/F · 2016.03.23 21:59

    Learn new knowledge, thank you for sharing! Look forward to more and better articles!

    enjoyed (0)Reply

    Programming Little Weng

    7/F · 2016.03.23 23:02

    Praise

    enjoyed (0)Reply

    Alexlearnstocod

    8/F · 2016.03.23 23:25

    Just to use, thank you!

    enjoyed (0)Reply

    Sanchain

    9/F · 2016.03.24 00:36

    Landlord hard, thank you

    enjoyed (0)Reply

    Surplus Sleeves Without fragrance

    10/F · 2016.03.24 01:04

    I'm a little white, but your article is great.

    enjoyed (0)Reply

    Ma_jack

    11/F · 2016.03.24 05:24

    ????

    enjoyed (0)Reply

    Not Daniel.

    12/F · 2016.03.24 11:18

    Learned the????????

    enjoyed (0)Reply

    Kimball

    13/F · 2016.03.24

    Much better than the original.

    enjoyed (0)Reply

    Laizw

    14/F · 2016.03.24 13:39

    Find the first source of the map

    enjoyed (2)Reply

    Mo Scar

    15/F · 2016.03.24 19:03

    Praise

    enjoyed (0)Reply

    About XX

    16/F · 2016.03.25 11:29

    Always think that video playback, video cutting and other processing is a more important place. But the work of the project has not met, time to study their own research

    enjoyed (0)Reply

    Load more

    Post a comment after logging in

    Find out more about similar topics by earning the following items:
      • Home Add attention

        The first step in the book is to start with this topic. Want to hit the top of the list? Does the good content want to be seen by more people? Let's contribute! Don't lose heart if you get rejected. The selected article will be in a team ...

        58,383 Articles · 101939 people follow

      • IOS Developer Add attention

        Share the knowledge of iOS development, solve the problems you encounter, discuss the frontiers of iOS development, and welcome to contribute ~

        6,341 Articles · 19263 people follow

      • iOS Learning Add attention

        Learn from the drip start! (PS: Rejected part of the article is only due to the topic has collected relevant knowledge points of the article, not the article is not submitted the technical content is not good enough, I hope to contribute ...

        2,694 Articles · 3389 people follow

    Talking about the n solution of iOS video playback

    Related Article

    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.