Discussion:
[patch][RFC] mpeg-ts not packetized properly over UDP
aviad rozenhek
2010-08-15 13:24:59 UTC
Permalink
when using ffmpeg to mux an mpegts stream over UDP, the data is not
packetized properly.
the default packet size of UDP is 1472, which is not an integer multiple of
188 (the TS packet size).
this causes problems if UDP packets are dropped or reordered.

this can be worked around from the commandline if changing cmdline from:
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234*
to:
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234?pkt_size=188*
*
*
however I think this makes it difficult for user to use properly.
attached is a simple (but not as efficient as possible) patch that fixes
this problem, by flushing after writing every TS packet.
--
Aviad Rozenhek
aviad rozenhek
2010-08-17 09:07:37 UTC
Permalink
Post by aviad rozenhek
when using ffmpeg to mux an mpegts stream over UDP, the data is not
packetized properly.
the default packet size of UDP is 1472, which is not an integer multiple of
188 (the TS packet size).
this causes problems if UDP packets are dropped or reordered.
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234*
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234?pkt_size=188
*
*
*
however I think this makes it difficult for user to use properly.
attached is a simple (but not as efficient as possible) patch that fixes
this problem, by flushing after writing every TS packet.
ping?
Michael Niedermayer
2010-08-17 12:02:54 UTC
Permalink
Post by aviad rozenhek
when using ffmpeg to mux an mpegts stream over UDP, the data is not
packetized properly.
the default packet size of UDP is 1472, which is not an integer multiple of
188 (the TS packet size).
this causes problems if UDP packets are dropped or reordered.
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234*
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234?pkt_size=188*
*
*
however I think this makes it difficult for user to use properly.
attached is a simple (but not as efficient as possible) patch that fixes
this problem, by flushing after writing every TS packet.
the udp packet size should be a multiple of the underlaying streams packet
size when possible and it should be as large as possible
making it 188 is not ok, this has too much overhead

[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato
Måns Rullgård
2010-08-17 10:19:26 UTC
Permalink
Post by Michael Niedermayer
Post by aviad rozenhek
when using ffmpeg to mux an mpegts stream over UDP, the data is not
packetized properly.
the default packet size of UDP is 1472, which is not an integer multiple of
188 (the TS packet size).
this causes problems if UDP packets are dropped or reordered.
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234*
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234?pkt_size=188*
*
*
however I think this makes it difficult for user to use properly.
attached is a simple (but not as efficient as possible) patch that fixes
this problem, by flushing after writing every TS packet.
the udp packet size should be a multiple of the underlaying streams packet
size when possible and it should be as large as possible
making it 188 is not ok, this has too much overhead
It is common to send 7 188-byte TS packets per UDP packet as this is
the maximum number which fits in a 1500-byte MTU.
--
Måns Rullgård
***@mansr.com
Stefan de Konink
2010-08-17 10:50:01 UTC
Permalink
Post by Måns Rullgård
It is common to send 7 188-byte TS packets per UDP packet as this is
the maximum number which fits in a 1500-byte MTU.
Doing an actual check what MTU the of the outgoing network is, and base
the value on that? Although the 7*188 probably covers all 'usual'
configurations (including VLAN trunking etc.)


Stefan
aviad rozenhek
2010-09-02 15:30:11 UTC
Permalink
Post by Michael Niedermayer
Post by aviad rozenhek
when using ffmpeg to mux an mpegts stream over UDP, the data is not
packetized properly.
the default packet size of UDP is 1472, which is not an integer multiple
of
Post by aviad rozenhek
188 (the TS packet size).
this causes problems if UDP packets are dropped or reordered.
the udp packet size should be a multiple of the underlaying streams packet
size when possible and it should be as large as possible
making it 188 is not ok, this has too much overhead
how about a solution in the spirit of this new attached patch?
aviad rozenhek
2010-09-05 09:32:51 UTC
Permalink
Post by aviad rozenhek
Post by Michael Niedermayer
Post by aviad rozenhek
when using ffmpeg to mux an mpegts stream over UDP, the data is not
packetized properly.
the default packet size of UDP is 1472, which is not an integer multiple
of
Post by aviad rozenhek
188 (the TS packet size).
this causes problems if UDP packets are dropped or reordered.
the udp packet size should be a multiple of the underlaying streams packet
size when possible and it should be as large as possible
making it 188 is not ok, this has too much overhead
how about a solution in the spirit of this new attached patch?
ping
Carl Eugen Hoyos
2010-09-06 10:27:06 UTC
Permalink
Post by aviad rozenhek
how about a solution in the spirit of this new attached patch?
Your patch contains a cosmetic change (that is forbidden) that adds a tab (which
is also forbidden), please consider using tools/patcheck.

Carl Eugen
aviad rozenhek
2010-09-07 14:51:13 UTC
Permalink
Post by Carl Eugen Hoyos
Post by aviad rozenhek
how about a solution in the spirit of this new attached patch?
Your patch contains a cosmetic change (that is forbidden) that adds a tab (which
is also forbidden), please consider using tools/patcheck.
Carl Eugen
sorry about that.
I can submit a proper patch if the idea behind it is agreed on.
aviad rozenhek
2010-09-14 21:25:05 UTC
Permalink
Post by Carl Eugen Hoyos
Post by aviad rozenhek
how about a solution in the spirit of this new attached patch?
Your patch contains a cosmetic change (that is forbidden) that adds a tab (which
is also forbidden), please consider using tools/patcheck.
Carl Eugen
sorry about that, here an updated patch.
it doesn't change anything for protocols that have no packet sizes such as
files, and changes the buffer for protocols that do.
for udp the buffer changes to 1316 bytes.
Carl Eugen Hoyos
2010-09-14 22:33:37 UTC
Permalink
+ init_put_byte(s->pb, s->pb->buffer, max_packet_size,
+ s->pb->write_flag, s->pb->opaque, s->pb->read_packet,
+ s->pb->write_packet, s->pb->seek);
+ init_put_byte(s->pb, s->pb->buffer, max_packet_size,
+ s->pb->write_flag, s->pb->opaque, s->pb->read_packet,
Carl Eugen
aviad rozenhek
2010-09-16 09:11:55 UTC
Permalink
+ init_put_byte(s->pb, s->pb->buffer, max_packet_size,
+ s->pb->write_flag, s->pb->opaque, s->pb->read_packet,
+ s->pb->write_packet, s->pb->seek);
+ init_put_byte(s->pb, s->pb->buffer, max_packet_size,
+ s->pb->write_flag, s->pb->opaque,
s->pb->read_packet,
Carl Eugen
fixed
Carl Eugen Hoyos
2010-09-16 09:28:07 UTC
Permalink
+ init_put_byte(s->pb, s->pb->buffer, max_packet_size,
+ s->pb->write_flag, s->pb->opaque,
s->pb->read_packet,
Carl Eugen
fixed
+ av_log(s, AV_LOG_ERROR, "max packet size %d", max_packet_size);
This line looks suspicious (as if it is printed in any case with a rather high
log level).

Carl Eugen
aviad rozenhek
2010-09-16 09:46:33 UTC
Permalink
Post by Carl Eugen Hoyos
+ init_put_byte(s->pb, s->pb->buffer, max_packet_size,
+ s->pb->write_flag, s->pb->opaque,
s->pb->read_packet,
Carl Eugen
fixed
+ av_log(s, AV_LOG_ERROR, "max packet size %d", max_packet_size);
This line looks suspicious (as if it is printed in any case with a rather high
log level).
Carl Eugen
Your absolutely right, its just a debugging line
shame on me for hacking at hours way past my bedtime.
fixed

atv_ffmpeg
2010-08-26 12:25:15 UTC
Permalink
Just modify udp.c in the folder called libavformat, change 1472 to 1316,
function 'udp_open'. It works fine. I already did it.
Post by aviad rozenhek
when using ffmpeg to mux an mpegts stream over UDP, the data is not
packetized properly.
the default packet size of UDP is 1472, which is not an integer multiple of
188 (the TS packet size).
this causes problems if UDP packets are dropped or reordered.
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234*
*> ffmpeg -re -i <input_file> -f mpegts udp://localhost:1234?pkt_size=188*
*
*
however I think this makes it difficult for user to use properly.
attached is a simple (but not as efficient as possible) patch that fixes
this problem, by flushing after writing every TS packet.
--
Aviad Rozenhek
_______________________________________________
ffmpeg-devel mailing list
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
Alexandre Ferrieux
2010-08-26 12:32:46 UTC
Permalink
Post by atv_ffmpeg
Just modify udp.c in the folder called libavformat, change 1472 to 1316,
function 'udp_open'. It works fine. I already did it.
1) Don't top post.

2) Of course it works. But hard-coding the TS-specific magic number 7*188 in place of the generic, MTU-related 1472 in
the muxer+codec-agnostic module udp.c, while a command-line override does it, is a bad idea.

Maybe some kind of information could flow from the TS container to the UDP url handler, to set it automatically ? Not
familiar enough with that part though. The command-line override is perfect in the meanime.

-Alex
Post by atv_ffmpeg
Post by aviad rozenhek
when using ffmpeg to mux an mpegts stream over UDP, the data is not
packetized properly.
the default packet size of UDP is 1472, which is not an integer multiple of
188 (the TS packet size).
this causes problems if UDP packets are dropped or reordered.
*> ffmpeg -re -i<input_file> -f mpegts udp://localhost:1234*
*> ffmpeg -re -i<input_file> -f mpegts udp://localhost:1234?pkt_size=188*
*
*
however I think this makes it difficult for user to use properly.
attached is a simple (but not as efficient as possible) patch that fixes
this problem, by flushing after writing every TS packet.
--
Aviad Rozenhek
_______________________________________________
ffmpeg-devel mailing list
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
_______________________________________________
ffmpeg-devel mailing list
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
Carl Eugen Hoyos
2010-08-26 13:41:05 UTC
Permalink
Post by Alexandre Ferrieux
1) Don't top post.
And please cut your quotes and please fix your line length.

Carl Eugen
Loading...