I am writing a RTSP publishing program using FFMPEG library.
The input is keeping reading a buffer that is reveicing data from a camera. I use a rtsp url as output. i.e. avformat_alloc_output_context2(&ofmt_ctx, NULL, "rtsp", output).
Now I need force the output to use TCP as rtsp_transpot. I've tried the following code. But it doesn't work. Is there any other ways to implement this ? Thanks.
AVDictionary *options = NULL;
av_dict_set(&options, "rtsp_transport", "tcp", 0);
ret = avformat_open_input(&fmt_ctx, avio_ctx->buffer, fmt_ctx->iformat, &options);
AVDictionary *options = NULL;
av_dict_set(&options, "rtsp_transport", "tcp", 0);
ret = avio_open2(&ofmt_ctx->pb, output, AVIO_FLAG_WRITE, NULL, &options);
I found it by myself.
use avformat_write_header(ofmt_ctx, &options);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With