One, compiled for the iOS Platform FFmpeg Library (Kxmovie) recently has a project, need to play various formats of audio, video and webcam real-time monitoring of video streaming data, after a variety of tossing, finally selected Kxmovie, Kxmovie Project has integrated ffmpeg and simple player, can refer to Kxmovie homepage: Https://github.com/kolyvan/kxmovie compilation Kxmovie is simple, has supported iOS 6.1 and armv7s, Once successful, the compilation process does not appear to have any problems:
git clone git://github.com/kolyvan/kxmovie.git
cd kxmovie
rake
Second, use Kxmovie 1. Add the Kxmovie/output folder file to the Project 2. Add frame: MediaPlayer, CoreAudio, Audiotoolbox, Accelerate, Quartzcore, Opengles and Libz.dylib,libiconv.dylib 3. Add Lib Library: Libkxmovie.a, LIBAVCODEC.A, Libavformat.a, LIBAVUTIL.A, Libswscale.a, Libswresample.a 4. Play Video:
ViewController *vc; vc = [KxMovieViewController movieViewControllerWithContentPath:path parameters:nil]; [self presentViewController:vc animated:YES completion:nil];
5. Specific use of the Reference demo project: Kxmovieexample Three, encountered problems playing local video and network video normal, playing webcam real-time monitoring video stream (H264) error occurred:
[Rtsp @ 0X906CC00] UDP timeout, retrying with TCP
[Rtsp @ 0X906CC00] nonmatching Transport in Server reply
[Rtsp @ 0X906CC00] Could not find codec parameters for stream 0 (video:h264): Unspecified size
Consider increasing the value for the ' analyzeduration ' and ' probesize ' options
Couldn ' t find stream information
Tracking code, the error is triggered when Avformat_find_stream_info gets the stream information failure.
if (Avformat_find_stream_info (Pformatctx,null) < 0) {
Av_log (NULL, Av_log_error, "couldn ' t find stream information\n");
Goto Initerror;
}
After a few days of groping, the final determination is the problem of the network (in the simulator play has been wrong, in the 3G network can play), the specific reason is estimated to be RSTP video stream, the program by default UDP transmission or multicast, resulting in the private network video stream is not normal transmission. Workaround, force the transmission mode of the video stream into a TCP transmission:
......
Open Video File
Pformatctx = Avformat_alloc_context ();
There are three modes of transmission: TCP Udp_multicast UDP, forcing TCP transmission
avdictionary* options = NULL;
Av_dict_set (&options, "Rtsp_transport", "TCP", 0);
if (Avformat_open_input (&pformatctx, [Moviepathcstringusingencoding:nsasciistringencoding],null,& Options)! = 0) {
Av_log (NULL, Av_log_error, "couldn ' t open file\n");
Goto Initerror;
}
Retrieve Stream Information
if (Avformat_find_stream_info (Pformatctx,null) < 0) {
Av_log (NULL, Av_log_error, "couldn ' t find stream information\n");
Goto Initerror;
} ......