2

I am using FFmpeg to read an rtsp camera. I am getting an error: ffmpeg rtsp error: Nonmatching transport in server reply in C++ and Invalid data found when processing input. The camera has setting "RTP ES". Here is the code.

source_name = "rtsp://192.168.1.108/WESCAM";

// Open the initial context variables that are needed
format_ctx = avformat_alloc_context();    
codec_ctx = NULL;

// Register everything
av_register_all();
avformat_network_init();
   
//open RTSP camera or h264 file
if (avformat_open_input(&format_ctx, source_name, NULL, NULL) != 0) 
{
    return EXIT_FAILURE;
}
evanhutomo
  • 627
  • 1
  • 11
  • 24
Douglas
  • 31
  • 4

1 Answers1

0

may this helpful:

AVDictionary *opts = nullptr;
av_dict_set(&opts, "rtsp_transport", "udp", 0); // here "udp" can replaced by "tcp"
avformat_open_input(&pFormatCtx, rtsp_addr, nullptr, &opts);
...
av_dict_free(&opts);
  • please give a Little more Information, like what does it do, and how it solves OPs problem – RealCheeseLord Aug 25 '17 at 08:02
  • Thanks - I have already tried that and it is still not working but is getting a different error. “Could not find codec parameters for stream 0 (Video: h264, none): unspecified size: Consider increasing the value for the ‘analyzeduration’ and ‘probesize’ options” When I issue the commands codec_ctx = avcodec_alloc_context3(codec); avcodec_get_context_defaults3(codec_ctx, codec); avcodec_parameters_to_context(codec_ctx, format_ctx->streams[video_stream_index]->codecpar); The width and height of the stream is 0 I'm using a VITEC MGW NANO dencoder – Douglas Aug 25 '17 at 14:04