iOS based on ffmpeg data (iv)

Source: Internet
Author: User

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;

} ......

iOS based on ffmpeg data (iv)

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.