I'm running the following GStreamer command:
gst-launch-1.0 -v filesrc location=audiofile.mp3 ! mad ! audioconvert ! rtpL16pay mtu=1024 ! udpsink port=5005 host=127.0.0.1
This sets up a RTP stream with a maximum packet size of 1024 bytes (Maximum Transmission Unit). When I run this stream, I end up getting a sequence of 4 packets of size 1024 followed by 1 packet of size 572. This sequence is repeated for the duration of the file. Why is this happening, and is there any way to ensure a uniform packet size (at least until the last packet)?
The RTP packet size is the minimum of either the MTU, max-ptime (if set) or available data.
So in your case, without more information, I suspect the packet size of 572 bytes is because it's all the available or remaining data in the pipeline at that point.
If you want to ensure 1024 bytes are always available, look into implementing a queue to buffer data for your rtpL16pay element.