In the posts, I will show how to use ffmpeg on iOS.
This posts is a document for this project:
https://github.com/lvjian700/ffmpegc-demo
Now, ffmpec support x264 module. If you use the script before, please check your version first.
What is ffmpeg ?
FFmpeg is a complete, across-platform solution to record, convert and stream audio and video.
Why use ffmpeg?
- Play h.264 video
- encoding capture video to h.264 video(It need ffmpeg h.264 module.)
- publish a av stream
- subscribe a rtsp av stream
Before use ffmpegc-demo, you should download and compile ffmpeg:
I made a repository to make the step easy:
If compile complete, you can find universal library in ffmpeg/build folder:
1. ffmpeg core library:
![编译ffmpeg for x264 ,H264编码解码 - hello world - hello world](https://i-blog.csdnimg.cn/blog_migrate/88d0e80ea2415748fb81df016bc83415.png)
2. ffmpeg x264 module. x264 is a H.264/MPEG-4 AVC encoder
![点击查看原始大小图片](https://i-blog.csdnimg.cn/blog_migrate/cad2524a6473b96f7268fe049e6b0b40.png)
Using ffmpeg
1. Clone project first:
2.Open in XCode and copy build/*.a and x264/build/*.a to libs/ folder of the project:
3. Add them to project link library
Project References -> Targets -> Build Phases -> Link Binary With Librarys
![点击查看原始大小图片](http://dl.iteye.com/upload/attachment/0077/0400/120bf08f-a399-329b-a977-bc412ab4a7f2.png)
4. Add dependences library:
Project References -> Targets -> Build Phases -> Link Binary With Librarys
Add two library:
- libbz.dylib
- libz.dylib
- libiconv.2.4.0.dylib
![编译ffmpeg for x264 ,H264编码解码 - hello world - hello world](http://dl.iteye.com/upload/attachment/0077/0405/76568674-6942-3d9c-919b-b7c265fc89a3.png)
5. Add Header Search Paths:
Project References -> Targets -> Build Settings ->
Header Search Paths
1. add ffmpeg core header paths:
![点击查看原始大小图片](http://dl.iteye.com/upload/attachment/0077/0407/97b61036-201b-37c9-8355-9500aa0ade29.png)
2. add x264 header paths:
![编译ffmpeg for x264 ,H264编码解码 - hello world - hello world](https://i-blog.csdnimg.cn/blog_migrate/0cfc63e0c7101edbaec3f12d495f6770.png)
6. Now, run project ...
Some useful document:
《How to prepare your mac for ios development with ffmpeg libraries》
《ffmpeg configure options》 -pdf
最后要个.sh里加上 --enable-encoder=libx264 才可以