First, compile the FFmpeg library (Kxmovie) for the iOS platform
Recently, there is a project that needs to play various formats of audio, video and webcam real-time monitoring of video streaming data, after a variety of tossing, finally selected the Kxmovie,kxmovie project has integrated ffmpeg and simple player, Refer to Kxmovie home page: Https://github.com/kolyvan/kxmovie compilation Kxmovie is simple, has supported iOS 6.1 and armv7s, a success, the compilation process did not have any problems:
git clone git://github.com/kolyvan/kxmovie.git
cd kxmovie
git submodule update --init
rake
Second, the use of kxmovie1.putKxmovie/output folder under File Add to Project 2. Add frame: MediaPlayer, CoreAudio, Audiotoolbox, Accelerate, Quartzcore, Opengles and Libz.dylib,libiconv.dylib3. Adding Lib Libraries: Libkxmovie.a, LIBAVCODEC.A, Libavformat.a, LIBAVUTIL.A, Libswscale.a, Libswresample.a4. Playing 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:nsasciistringencodingnull &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;
}......