video – FFMPEG convert RTSP to MPEG-TS with constant size packets

I have an RTSP stream which I want to convert, via FFMPEG, to an MPEG-TS stream with constant size UDP packets.
I have played around with many FFMPEG options and the closest one I’ve found so far is this:
ffmpeg -i rtsp://localhost:123 -f rtp_mpegts udp://localhost:456
This produces a stream of packets of size 1328, which is equivalent to 7 MPEG-TS packets (188 bytes each) plus a 12-byte RTP header. However, I don’t want to have an RTP header. I could remove this programmatically but I’d rather figure out how to get FFMPEG to do it properly.

I haven’t been able to find a combination of options which results in constant-size packets with the -f mpegts option. How do I tell the muxer how many MPEG-TS packets I want in each UDP packet?

ffmpeg -i rtsp://localhost:123 -f rtp_mpegts udp://localhost:456
-> packets with Len=1328
ffmpeg -i rtsp://localhost:123 -f mpegts udp://localhost:456?pkt_size=1316
-> packets with lengths from 220-1348 (1-7 MPEG-TS packets)

Read more here: Source link