Packet size cap for rtpmp2tpay2 only works for 188 standard TS packet

As per the docs, rtpmp2tpay2 accepts a TS packet size of 188, 192, 204, 208.
However, when I feed a 192 packet size it complains about the buffer size.

net/rtp/src/mp2t/pay/imp.rs(258): <gstrsrtp::mp2t::pay::imp::RtpMP2TPay as gstrsrtp::basepay::RtpBasePay2Impl>::handle_buffer (): /GstPipeline:pipeline0/GstRtpMP2TPay2:rtpmp2tpay2-0:
MPEG-TS packet size 192 but buffer is 12972 bytes

My sample file is an m2ts file. BDAV MPEG-2 TS stream.
sample file: https://filesamples.com/samples/video/m2ts/sample_960x400_ocean_with_audio.m2ts

I’m afraid this part of the code will not accept 192 packet size. Sorry if I’m wrong here.

The pipeline I’m using is as below.

gst-launch-1.0 splitfilesrc location=/data/sample_960x400_ocean_with_audio.m2ts ! tsparse set-timestamps=true  ! rtpmp2tpay2 pt=103 ! .send_rtp_sink_0 rtpbin ! udpsink host=239.202.0.4 port=4000

I tried to set alignment in tsparse but couldn’t get it to work.
I got it working by transcoding the stream and remuxing it using m2ts-mode property of mpegtsmux but I really don’t want to transcode the stream as I believe the m2ts file should have the TS packets in required size.

Any suggestions would be helpful, thanks!

Thanks for giving the new Rust RTP payloader a spin.

It looks like the payloader complains because 12972 / 192 = 67.5625, so the buffer does not contain an integral number of packets, which is what it expects here.

I will double-check whether that assumption is correct, but to me this smells like a tsparse issue then perhaps.

Oh, let me debug from tsparse side then. Perhaps I can find something. Last time I checked the mpegtspacketizer it was handling M2TS packets.

It looks like tsparse might be stripping the 4 byte timestamp extension off the 192 byte packets and be outputting 188 byte packets while claiming to output 192 byte packets.

tsparse pushing 188 size buffer as per the logs I got.

0:00:00.027897657  3514 0x55ae919f2240 LOG                  tsparse mpegtsparse.c:1056:mpegts_parse_have_buffer:<mpegtsparse2-0> Received buffer buffer: 0x7ff1080201f0, pts 99:99:99.999999999, dts 0:00:00.000000000, dur 99:99:99.999999999, size 188, offset none, offset_end none, flags 0x0
0:00:00.027903479  3514 0x55ae919f2240 LOG                  tsparse mpegtsparse.c:879:mpegts_parse_inspect_packet: pid 0x1011 pusi:0, afc:16, cont:5, payload:0x7ff100004f90 PCR 18446744073709551615
0:00:00.027909541  3514 0x55ae919f2240 LOG                  tsparse mpegtsparse.c:1056:mpegts_parse_have_buffer:<mpegtsparse2-0> Received buffer buffer: 0x7ff1080204a0, pts 99:99:99.999999999, dts 0:00:00.000000000, dur 99:99:99.999999999, size 188, offset none, offset_end none, flags 0x0
0:00:00.027915362  3514 0x55ae919f2240 LOG                  tsparse mpegtsparse.c:879:mpegts_parse_inspect_packet: pid 0x1011 pusi:0, afc:16, cont:6, payload:0x7ff100005050 PCR 18446744073709551615
0:00:00.027921536  3514 0x55ae919f2240 LOG                  tsparse mpegtsparse.c:1056:mpegts_parse_have_buffer:<mpegtsparse2-0> Received buffer buffer: 0x7ff108020750, pts 99:99:99.999999999, dts 0:00:00.000000000, dur 99:99:99.999999999, size 188, offset none, offset_end none, flags 0x0
0:00:00.027961077  3514 0x55ae919f2240 LOG                  tsparse mpegtsparse.c:651:empty_adapter_into_pad:<mpegtsparse2-0:src> prev pts:0:00:00.030586110 (dist:376) dts:0:00:00.030586110 (dist:376)
ERROR: from element /GstPipeline:pipeline0/GstRtpMP2TPay2:rtpmp2tpay2-0: MPEG-TS input is not properly framed
Additional debug info:
net/rtp/src/mp2t/pay/imp.rs(258): <gstrsrtp::mp2t::pay::imp::RtpMP2TPay as gstrsrtp::basepay::RtpBasePay2Impl>::handle_buffer (): /GstPipeline:pipeline0/GstRtpMP2TPay2:rtpmp2tpay2-0:
MPEG-TS packet size 192 but buffer is 2632 bytes

The mpegtspacketizer is calculating correct offset for a 192 packetsize.

0:00:00.194868666 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 0
0:00:00.209437136 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 192
0:00:00.210027079 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 384
0:00:00.210160436 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 576
0:00:00.210244341 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 768
0:00:00.210324122 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 960
0:00:00.210404888 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 1152
0:00:00.210571815 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 1344
0:00:00.210779015 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 1536
0:00:00.210961089 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 1728
0:00:00.211167837 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 1920
0:00:00.211310437 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 2112
0:00:00.211481062 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 2304
0:00:00.212045261 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 2496
0:00:00.212825194 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 2688
0:00:00.213388321 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 2880
0:00:00.213631857 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 3072
0:00:00.213856879 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 3264
0:00:00.214093747 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 3456
0:00:00.214278303 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 3648
0:00:00.214572472 ESC[32m 9775ESC[00m 0x563366acc240 ESC[33;01mLOG    ESC[00m ESC[00m    mpegtspacketizer mpegtspacketizer.c:887:mpegts_packetizer_next_packet:ESC[00m offset 3840

From above I believe tsparse is getting correct packet->data_start and packet->data_end while it is trying to fill the buffer.

Not sure if I’m getting the ordering of functions calls correct.