Avformat_find_stream_info function Stuck problem

Source: Internet
Author: User

Issue: When initializing the RTSP stream, the Avformat_find_stream_info function is stuck on the Android device, and then the program crashes.

But the other URL is not a problem, and the same in the code on iOS no problem, due to JNI debugging, also did not see FFMEPG print what unusual information, and iOS can see the following printing information

[OBJC]View Plaincopy
    1. Avformat_open_input ret= 0
    2. UDP timeout, retrying with TCP

See this at that time unexpectedly did not respond to come over, know to see reference link explanation only discovered.

The code is as follows:

[OBJC]View Plaincopy
  1. Av_register_all ();
  2. Av_log_set_level (Av_log_debug);
  3. Av_log_set_callback (Log_callback);
  4. Avformat_network_init ();
  5. ret = avformat_open_input (&formatctx, URL, null, null);
  6. NSLog (@ "Avformat_open_input ret=%d", ret);
  7. if (Ret < 0) {
  8. NSLog (@ "Avformat_open_input error=%d", ret);
  9. return ret;
  10. }
  11. ret = Avformat_find_stream_info (formatctx, NULL); It's jammed here,
  12. NSLog (@ "Avformat_find_stream_info ret=%d", ret);
  13. if (Ret < 0) {
  14. NSLog (@ "Avformat_find_stream_info error=%d", ret);
  15. return ret;
  16. }

Workaround:

Specified as a TCP transport.

[OBJC]View Plaincopy
    1. avdictionary* options = NULL;
    2. Av_dict_set (&options, "Rtsp_transport", "TCP", 0);
    3. ret = avformat_open_input (&formatctx, URL, NULL, &options);




Reference Links:

Http://www.bkjia.com/IOSjc/874706.html

Reprint: http://blog.csdn.net/fb731666148/article/details/44408379

Avformat_find_stream_info function Stuck problem

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.