How would I go about reading from an RTP stream and saving the video from
said rtp stream into a different output format (say, an mp4)?
The following code appears to do just that, but for some reason does not
work. When I decode/re-encode the packet, it works just fine.
inputFormatCtx is an RTP stream (I use an SDP file as my input file)
outputFormatCtx is an mp4 context.
while(av_read_frame(inputFormatCtx, &inputFramePacket) >= 0)
{
if(inputFramePacket.stream_index == videoStreamIndex)
{
AVPacket pkt;
av_init_packet(&pkt);
if(inputFramePacket.flags & PKT_FLAG_KEY)
pkt.flags |= PKT_FLAG_KEY;
pkt.stream_index = inputFramePacket.stream_index;
pkt.data = inputFramePacket.data;
pkt.size = inputFramePacket.size;
av_write_frame(outputFormatCtx, &pkt);
}
av_free_packet(&inputFramePacket);
}
It should also be noted that in my actual implementation, I am decoding the
inputFramePacket (because I am also rendering it to screen). Not sure if
this would matter though...
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user