iOS uses ffmpeg playback RSTP real-time monitoring of video data streams

Source: Internet
Author: User

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;

    }......

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.