[FFmpeg-devel] Demuxing and decoding raw RTP stream
Kevin Wang
kevmo314 at gmail.com
Sat Feb 5 20:09:02 EET 2022
Hi, I'm implementing a pipeline where I receive inbound RTP packets in
memory but I'm having trouble figuring out how to set up libavformat to
handle/unwrap the RTP packets.
I have all relevant information about the underlying codec necessary but
since it's h264 I cannot simply strip the RTP header trivially. I create
the input context with goInputFunction writing one packet per invocation.
void *readbuf = av_malloc(1500);
AVIOContext *avioreadctx = avio_alloc_context(readbuf, 1500, 0,
transcoder, &goInputFunction, NULL, NULL);
AVFormatContext *inputctx = avformat_alloc_context();
inputctx->pb = avioreadctx;
inputctx->flags |= AVFMT_FLAG_CUSTOM_IO;
When I open it with avformat_open_input(&inputctx, NULL, NULL, NULL) it
repeatedly calls the read function but doesn't actually progress. I suspect
because the RTP stream itself does not have enough information to fully
describe the codec? If I leave this open out, then av_read_frame(inputctx,
input_packet) down the road segfaults, I'm guessing because the input
context is uninitialized.
So to my question, is it possible to set the codec details that the SDP
would typically set, but manually?
I'm looking for an example of how to manually configure the AVFormatContext to
consume RTP packets without an SDP and setting up a UDP port listener.
Thanks,
Kevin
More information about the ffmpeg-devel
mailing list