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
- Avformat_open_input ret= 0
- 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
- Av_register_all ();
- Av_log_set_level (Av_log_debug);
- Av_log_set_callback (Log_callback);
- Avformat_network_init ();
- ret = avformat_open_input (&formatctx, URL, null, null);
- NSLog (@ "Avformat_open_input ret=%d", ret);
- if (Ret < 0) {
- NSLog (@ "Avformat_open_input error=%d", ret);
- return ret;
- }
- ret = Avformat_find_stream_info (formatctx, NULL); It's jammed here,
- NSLog (@ "Avformat_find_stream_info ret=%d", ret);
- if (Ret < 0) {
- NSLog (@ "Avformat_find_stream_info error=%d", ret);
- return ret;
- }
Workaround:
Specified as a TCP transport.
[OBJC]View Plaincopy
- avdictionary* options = NULL;
- Av_dict_set (&options, "Rtsp_transport", "TCP", 0);
- 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