Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg coding force rtsp output stream use TCP as rtsp_transport

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);
like image 244
Kevin Avatar asked Nov 15 '25 15:11

Kevin


1 Answers

I found it by myself.

use avformat_write_header(ofmt_ctx, &options);

like image 158
Kevin Ouyang Avatar answered Nov 18 '25 20:11

Kevin Ouyang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!