IOS uses ffmpeg to play rstp real-time monitoring video data streams

Source: Internet
Author: User

IOS uses ffmpeg to play rstp real-time monitoring video data streams
I. Compile the ffmpeg Library (kxmovie) for the iOS platform. Recently, a project needs to play audio, video, and video stream data monitored in real time by the Network Camera in various formats, finally selected kxmovie, kxmovie project has integrated ffmpeg and simple player, specific can refer to kxmovie home page: https://github.com/kolyvan/kxmovieCompiling kxmovie is simple and supports iOS 6.1.AndArmv7s, once successful, there is no problem in the compilation process:

git clone git://github.com/kolyvan/kxmovie.git
cd kxmovie
git submodule update --init 
rake
2. Use kxmovie1. to add files in the kxmovie/output Folder to the project. 2. added frameworks: MediaPlayer, CoreAudio, AudioToolbox, Accelerate, QuartzCore, OpenGLES and libz. dylib, libiconv. dylib3. Add the lib Library: libkxmovie. a, libavcodec. a, libavformat. a, libavutil. a, libswscale. a, libswresample. a4. play the video:
ViewController *vc;    vc = [KxMovieViewController movieViewControllerWithContentPath:path parameters:nil];    [self presentViewController:vc animated:YES completion:nil]; 
5. For details, refer to the demo project: KxMovieExample 3. If you encounter any problems, you may encounter an error when playing the local and online videos normally. When playing the real-time monitoring video stream of the Network Camera (h264:

[Rtsp @ 0x906cc00] UDP timeout, retrying with TCP

[Rtsp @ 0x906cc00] Nonmatching transport in server reply

[Rtsp @ 0x906cc00] cocould 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 fails to obtain the stream information.

If (avformat_find_stream_info (pFormatCtx, NULL) <0 ){

Av_log (NULL, AV_LOG_ERROR, "Couldn't find stream information \ n ");

Goto initError;

}

After several days of exploration, it was finally determined that it was a network problem (the simulator has been playing an error and can be played in 3G networks). The specific cause is estimated to be rstp video streams, by default, the program uses udp transmission or multicast. As a result, video streams in the private network cannot be transmitted normally. Solution: force the video stream transmission mode to tcp transmission:

......

// Open video file

PFormatCtx = avformat_alloc_context ();

// There are three transmission modes: tcpUdp_multicast udp, forced to use 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;

}......

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.